in reply to Re^2: Introspection into floats/NV
in thread Introspection into floats/NV

I wrote this before %a was introduced. But %a produces scientific notation, whereas the above doesn't.

Replies are listed 'Best First'.
Re^4: Introspection into floats/NV
by LanX (Saint) on Jun 03, 2025 at 16:55 UTC
    > But %a produces scientific notation, whereas the above doesn't.

    my issue with %a is rather that it's called "hex float" but the exponent is decimal ... LOL.

    I'm happy that it exists anyway, since different builds can have other floats configured, plattforms have various endianness too.

    Furthermore it's a valid number format in Perl.

    DB<18> say 0x1p+10 - 1 1023

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

      I was using it to find the periodic portion.

      0.1 = 0.00011001100110011001100110011001100110011001100110011010 ____ = 0.00011
        I think there is a generic formula to calculate these using prime factors.

        But I get your point, seeing the periodic portion in hex would be different.

        While the period's length might be the same, the discrepant becomes only one quarter of what it was.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        see Wikisyntax for the Monastery