Settings

Theme

To Infinity but Not Beyond

meyerweb.com

45 points by roosgit 7 months ago · 2 comments

Reader

mananaysiempre 7 months ago

At the risk of pointing out the obvious: (1-2^-24) × 2^128 ≈ 3.40282e+38 is the maximum finite single-precision (32-bit) floating-point value, (1-2^-53) × 2^1024 ≈ 1.79769e+308 is the maximum finite double-precision (64-bit) one, and 2^15 = 32767 and 2^31 = 2147483647 are of course the maximum signed 16-bit and 32-bit integer respectively. Also, 2^25 = 33554428 + 4 = 33554400 + 32, which I don’t see a good reason for.

Don’t know why browsers don’t use actual floating-point infinies (which, yes, obey a + Inf = Inf [edit: Inf not a] and a × Inf = (sgn a) Inf for finite a, which should in fact have been covered in either an assembly course or a numerics course). I’m guessing something on the Web ended up subtracting Inf - Inf = NaN and crapping out.

  • tialaramex 7 months ago

    You wrote "a + Inf = a" but er, presumably you meant "a + Inf = Inf" where a is some finite float ?

    These are intuitive mathematical properties but would need to also be underscored for the IEEE floats because the relationship between the reals (which we definitely can't generally handle with a computer) we learned in school and the floats implemented by today's machines is unclear to many programmers. You absolutely can't expect people whose only language is Javascript to understand e.g. "floats aren't normal" even to the level of laughing at a T-shirt joke.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection