I was surprised to find out that 27**(1/3) == int 27**(1/3) and tried to introspect what the double float in the NV contains. I spend hours fiddling with printf , pack , unpack and (worst) the bit-order on intel processors to create this
(compare https://bartaz.github.io/ieee754-visualization/ )
$ perl printf "%5s %.13a\n %s\n", $_, eval($_), unpack("B*",pack("F>",ev +al $_)) for qw(1 -1 2 -2 1/3 -1/3) __END__ 1 0x1.0000000000000p+0 0011111111110000000000000000000000000000000000000000000000000000 -1 -0x1.0000000000000p+0 1011111111110000000000000000000000000000000000000000000000000000 2 0x1.0000000000000p+1 0100000000000000000000000000000000000000000000000000000000000000 -2 -0x1.0000000000000p+1 1100000000000000000000000000000000000000000000000000000000000000 1/3 0x1.5555555555555p-2 0011111111010101010101010101010101010101010101010101010101010101 -1/3 -0x1.5555555555555p-2 1011111111010101010101010101010101010101010101010101010101010101
2 questions:
Platform: osname=linux osvers=6.1.0 archname=x86_64-linux-gnu-thread-multi Compiler: cc='x86_64-linux-gnu-gcc'
tested on my ARM mobile which has another endianess, and got the same result
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
In reply to Introspection into floats/NV by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |