Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Yet again: floats are not expressed accurately

by pryrt (Abbot)
on Mar 21, 2023 at 14:36 UTC ( [id://11151104]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        float x = 226.0;
        if( ABS(x-226.0)>0.00000001 ){ printf("ajaja\n"); }
    
  2. or download this
    perl -V:nvsize -V:nvtype
    nvsize='8';
    nvtype='double';
    
  3. or download this
    /* gcc a.c */
    #include <stdio.h>
    ...
        printf("2.26*100=%.16lf\n", d);
        if( ABS(d-226.0)>=2.842e-14 ){ printf("double-ULP check has ABS er
    +ror\n"); } else {printf("double-ULP check OK\n");}
    }
    
  4. or download this
    version=2.260000, newversion=2.270000
    2.26*100=226.00000000
    ...
    float-ULP check OK
    2.26*100=225.9999999999999700
    double-ULP check has ABS error
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-03-28 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found