News for hackers. Stuff that matters.
Re:Perfect Random Floating-Point Numbers by thaumasiotes on Wednesday May 07, 2025 @02:04PM (#43918850)
> The floats are a surprisingly bad approximation of the reals. They're barely better than the integers

They are integers. Each float is a pattern of 64 discrete bits. Discretion means integers.

Re:Perfect Random Floating-Point Numbers by kbolino on Wednesday May 07, 2025 @05:12PM (#43920609)
In float32 land, if

    x   = 0.5   (with bit pattern 0x3f000000)
    y   = 0.25  (with bit pattern 0x3e800000)
then

    x+y = 0.75  (with bit pattern 0x3f400000)
But if we just added the bit patterns like integers, we would get 0x7d800000 (with a float value of over 10^37). Just because they are discrete doesn't mean they are integers only that they can be mapped one-to-one with integers. The bit pattern is not the semantic meaning of the value, and you cannot perform correct operations if you ignore the semantics.