in reply to Re: hexadecimal division
in thread hexadecimal division

> hexadecimal is just another representation format for the more abstract concept of an integer

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 :)

update

yep

DB<1> p $] 5.024001 DB<2> p 0x1.999Ap-4 0.100000381469727

Though not mentioned in perlnumber yet

update

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.

more testing

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
    hexadecimal floats

    Yep, that's why I said "I'll just talk about integers for now" - but I could have worded it better, thank you for pointing that out! I've updated the node.

      No critic at all - that's a stunning new feature I really love. :)

      It's rather the fact it's not mentioned in perlnumber that drove me to this post.

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

Re^3: hexadecimal division
by choroba (Cardinal) on Dec 16, 2017 at 21:07 UTC
    Yes, 5.22.
    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,