[erlang-bugs] io_lib_format:fwrite_g/1 on arm

George Bronnikov yura.bronnikov@REDACTED
Fri May 23 16:22:22 CEST 2008

In recent versions (since R12B0?), io_lib_format:fwrite_g/1, which is
the default function for printing floats, analyzes its argument using
a bit pattern (mantissa_exponent is a helper function called from

mantissa_exponent(F) ->
    case <<F:64/float>> of
        <<_S:1, 0:11, M:52>> -> % denormalized
            E = log2floor(M),
            {M bsl (53 - E), E - 52 - 1075};
        <<_S:1, BE:11, M:52>> when BE < 2047 ->
            {M + ?BIG_POW, BE - 1075}

Unfortunately, on Linux/arm (at least in my configuration), a float
has its 32-bit words swapped, so the function produces garbage.
Reverting to the version from R11B-4 (which just calls fwrite_g/4 with
appropriate defaults) gets rid of the bug.

Configuration: iPaq3900, Familiar 0.8.4, Linux
2.4.19-rmk6-pxa1-hh41.1, glibc 2.3.90, gcc-3.4.4.


More information about the erlang-bugs mailing list