Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I know I'm resurrecting an ancient thread, but I was looking at this again while thinking about my Expand.pm module: I think the counts you showed were off: of the 2**64 = 18e18 combinations of the 64bit value, you listed 18e15 non-normalized numbers, of which 9e15 were denormalized, 18e18 were signaling NaN, and 18e18 were quiet NaN, which didn't quite add up right. :-) Here are my tallies:

Zeroes plus denormals are all the combinations that have the 11 exponent bits of 000_0000_0000, that is:

*_000_0000_0000_****_****_****_****_****_****_****_****_****_****_ +****_****_**** => 2^53 = 9,007,199,254,740,992 => #zeroes = 2 => #denormals = 9,007,199,254,740,990 => #positive = 4,503,599,627,370,495 => #negative = 4,503,599,627,370,495

Infinities plus NaNs take all combinations that have the 11 exponent bits of 111_1111_1111, that is:

*_000_0000_0000_****_****_****_****_****_****_****_****_****_****_ +****_****_**** => 2^53 = 9,007,199,254,740,992 => #infinities = 2 => #NaNs= 9,007,199,254,740,990 => #signalling = 4,503,599,627,370,495 => #quiet = 4,503,599,627,370,495

That should leave 2**64 - 2*(2**53) for normalized numbers:

18,446,744,073,709,551,616 = #64bit values - 18,014,398,509,481,984 = #zeroes + #infinities + #denormal + # +NaN = 18,428,729,675,200,069,632 = #normalized numbers

Confirming 2**52, 2**53, 2**54, 2**64, and 2**64 - 2**54 :

cmd.exe> perl -MMath::BigInt -E "$b = Math::BigInt->new(2); my $x = ($ +b**$ARGV[0]); $x =~ s/(\d{1,3}?)(?=(\d{3})+$)/$1,/g ; say $x" 52 4,503,599,627,370,496 cmd.exe> perl -MMath::BigInt -E "$b = Math::BigInt->new(2); my $x = ($ +b**$ARGV[0]); $x =~ s/(\d{1,3}?)(?=(\d{3})+$)/$1,/g ; say $x" 53 9,007,199,254,740,992 cmd.exe> perl -MMath::BigInt -E "$b = Math::BigInt->new(2); my $x = ($ +b**$ARGV[0]); $x =~ s/(\d{1,3}?)(?=(\d{3})+$)/$1,/g ; say $x" 54 18,014,398,509,481,984 cmd.exe> perl -MMath::BigInt -E "$b = Math::BigInt->new(2); my $x = ($ +b**$ARGV[0]); $x =~ s/(\d{1,3}?)(?=(\d{3})+$)/$1,/g ; say $x" 64 18,446,744,073,709,551,616 cmd.exe> perl -MMath::BigInt -E "$b = Math::BigInt->new(2); $p1 = Math +::BigInt->new($ARGV[0]); $p2 = Math::BigInt->new($ARGV[1]); $x = $b** +$p1; $y = $b**$p2; $z = $x-$y; say join qq|\n|, map { s/(\d{1,3}?)(?= +(\d{3})+$)/$1,/g; $_ } $x, $y, $z;" 64 54 18,446,744,073,709,551,616 18,014,398,509,481,984 18,428,729,675,200,069,632


In reply to Re: Exploring IEEE754 floating point bit patterns. by pryrt
in thread Exploring IEEE754 floating point bit patterns. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-16 20:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found