Manipulating IEEE754 32bit floats (incl mapping 64bit double)

You won't get multiple types of infinity (other than +/-).

I have learned that besides + & -, there is 'countable' infinity (the numbers in N, Z or Q) and 'uncountable' infinity (numbers in R and C).

Countable infinity you can devise a way to enumerate all the items in an infinite set. Trivial for N, for Z you alternate between pos/neg. (Q is a bit more complex)
For uncountable sets like R there is always an infinite set between 2 values.

Back to the original subject, for IEEE754 I can imagine 2 (more) types of infinity:

FLOAT_INF: a value does not fit in a float (32bit)
DOUBLE_INF: a value does not fit in a double (64bit)
DOUBLE_DOUBLE_INF: idem 128 bit.
...
INFINITY = will not fit in any size float
(so there will be an infinite definitions of infinite :wink:

maybe name them F32_INF, F64_INF, F128_INF, etc.
F32_inf would be { 0, 255, 32 } for float32 // sign, exp, mantissa
F64_inf == { 0, 255, 64 } for float; and { 0, 2047, 64 } for double;
F128_inf == { 0, 255, 128 } or {0,2047, 128}
in general: { s=sign, e=MAXEXP, m=infinite size } // MAXEXP + next bit 0, indicates infinity

maybe a better form of infinite would be: {s, MAXEXP, m=#bits needed to represent the number, 0 == unknown }
as the 32 bit float has a mantissa of 23 bits it could indicate that a number needs more than a 4million bits or 1 million digits.

{ 0, MAXEXP, 1600 } is an infinite number that would require 1600 bits to represent (or about 400+digits).

This could make OrderOfMagnitude math possible, even in infinite. e.g. { 0, MAXEXP, 300 } / { 0, MAXEXP, 250 } ==> { 0, MAXEXP, 50}

a simple way might be to fill the mantissa with the exponent before truncating it to MAXEXP.
example:
1E30 * 1E30 ==> overflow as 1E60 does not fit in float ==> {s, MAXEXP, 60 } // exponent is truncated to MAXEXP to indicate infinity.

Some calculators show the mantissa and an E for Error. At least that gives you an indication of what the number looks like (starts with)


A number not seen in the IEEE754 which would be nice to have is EPSILON,
the number that can not be represented but is slightly more than zero (and of course -EPSILON)
would be more interesting as the rounding to ZERO

</thinking out loud>