in reply to Re: hexadecimal division
in thread hexadecimal division
minor nitpick, to my surprise it's now possible to define hexadecimal floats.
see perldata#Scalar-value-constructors
0x1.999ap-4 # hexadecimal floating point (the "p" is required)
couldn't test yet, seems to be newer than 5.16 :)
yep
DB<1> p $] 5.024001 DB<2> p 0x1.999Ap-4 0.100000381469727
Though not mentioned in perlnumber yet
seems to work, the exponent 4 counts to the power of 2 (NOT 16 or 256). (16**4 is there to move the fraction point)
DB<37> p 0x1999A /16**4 /2**4 0.100000381469727
And it becomes obvious why p was used since an E is a valid hex digit.
DB<49> eval qq{print 0x1p${_},"\n"} for -4..4 0.0625 0.125 0.25 0.5 1 2 4 8 16
Hex fraction point moves with each 4 power steps (since 16 == 2**4 )
DB<58> x 0x10 , 0x1.0p4 , 0x1.0p0 , 0x10p-4 0 16 1 16 2 1 3 1
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: hexadecimal division (hexadecimal floating point -updated)
by haukex (Archbishop) on Dec 16, 2017 at 21:24 UTC | |
by LanX (Saint) on Dec 16, 2017 at 21:35 UTC | |
|
Re^3: hexadecimal division
by choroba (Cardinal) on Dec 16, 2017 at 21:07 UTC |