demofox on Nostr: TIL about floating point math: float w=a*b; float e=fma(-a,b,w); w is the closest ...
TIL about floating point math:
float w=a*b;
float e=fma(-a,b,w);
w is the closest float possible to the real answer of a*b, but the difference between that and the actual answer can be significant.
e is that difference, and apparently the difference is exactly representable as a float.
Published at
2026-08-14 01:23:06 UTCEvent JSON
{
"id": "21772baa86a8e45045c08a477fb85f4a73164d7fce8d539d7fb25b8bdde6bf1b",
"pubkey": "bdbfe8fd7113a03f04905b60971166be57d7105c6741e1f6945c46d10d102fab",
"created_at": 1786670586,
"kind": 1,
"tags": [
[
"proxy",
"https://mastodon.gamedev.place/@demofox/117091243548373952",
"web"
],
[
"proxy",
"https://mastodon.gamedev.place/users/demofox/statuses/117091243548373952",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://mastodon.gamedev.place/users/demofox/statuses/117091243548373952",
"pink.momostr"
],
[
"-"
]
],
"content": "TIL about floating point math:\n\nfloat w=a*b;\nfloat e=fma(-a,b,w);\n\nw is the closest float possible to the real answer of a*b, but the difference between that and the actual answer can be significant.\n\ne is that difference, and apparently the difference is exactly representable as a float.",
"sig": "974401b05f8b2c2392d24690ef25a22a9bf090c91f420b6e8881f6df932f20665adf13dec4b5a509abb1294e5bcf74424b12a4da87d1f934a7c2976bb68f7f2e"
}