Get floating point representation in memory

After all, I’ve added float_parts/4 with these docs.

float_parts(+Float, -Mantissa, -Base, -Exponent)                                           [det]
    True when Mantissa is the normalized fraction of Float, Base  is the  radix and  Exponent is
    the exponent. This uses the C function frexp(). If  Float is  NaN or  ±Inf Mantissa  has the
    same value and Exponent is 0 (zero). In  the current  implementation Base  is always  2. The
    following relation is always true

        Float =:= Mantissa × Base^Exponent

I consider this a special case. It is a simple wrapper around C frexp(). I have deliberately omitted to make this multi-moded. It is not necessary and I want to keep this simple. I also deliberately did not include the direct memory layout. This should remain hidden to accommodate other float formats. The core relation above is (I hope) the basis of floating points and thus true for any float infrastructure we may use in the future. If you really want the memory, you need to use foreign code.

1 Like