Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Perl Monk, Perl Meditation
 
PerlMonks  

May I be bitten by floating point arithmetic in the following restricted case?

by rubasov (Friar)
on Feb 23, 2010 at 17:40 UTC ( #824902=perlquestion: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    0 <= SIZE < 1
    1 <= SIZE < 2
    2 <= SIZE < 4
    4 <= SIZE < 8
    and so on...
    
  2. or download this
    $size_class = $size ? int( log($size) / log(2) ) : -1;
    # red light on, possible error caused by floating point arithmetic
    
  3. or download this
    bash $ diff <( perl -E 'say int( log(2**$_) / log(2) ) for 1 .. 2**10'
    + ) <( seq 1 $(( 2**10 )) )
    
  4. or download this
    1024c1024
    < inf
    ---
    > 1024
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://824902]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-04-18 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (460 votes), past polls