Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Variables are automatically rounded off in perl

by syphilis (Archbishop)
on Feb 11, 2019 at 07:38 UTC ( #1229754=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    C:\>perl -le "print 'ok' if 3335.9999999999995 > 3335.999999999999;"
    ok
    
  2. or download this
    C:\>perl -le "print 3335.9999999999995; print 3335.999999999999;"
    3336
    3336
    
  3. or download this
    C:>perl -le "print 'ok' if 3335.9999999999995 + 0.0000000000001 == 333
    +5.9999999999995;"
    ok
    
  4. or download this
    C:\>perl -le "print 3335.9999999999995;"
    3336
    
  5. or download this
    printf "%a", $float;
    or
    printf "%.16e", $float;
    
  6. or download this
    C:\>perl -MMath::MPFR=":mpfr" -le "print nvtoa(2 ** -1074);"
    5e-324
    
    C:\>perl -MMath::MPFR=":mpfr" -le "print nvtoa(sqrt 2.0);"
    1.4142135623730951
    
  7. or download this
    use POSIX qw(strtod);
    $x = strtod('1234e-5');
    
  8. or download this
    $x = 1234e-5;
    
  9. or download this
    use Math::MPFR qw(:mpfr);
    $x = atonv('1234e-5');
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1229754]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-05-22 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (78 votes). Check out past polls.

    Notices?