Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^4: Variables are automatically rounded off in perl

by syphilis (Archbishop)
on Feb 11, 2019 at 07:38 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-18 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found