Re: surprising precision

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/3/2010 12:51 PM, me22 wrote:
On 3 March 2010 15:29, Jonathan<jsealy@xxxxxxxxx>  wrote:
It has not received any explanations yet.
On the one hand it appears not to be a problem but on the other hand could
be a spectacular bug.

It's probably just you not understanding what floating point numbers are.

Go read http://en.wikipedia.org/wiki/IEEE_754-2008
Also, be careful about what you call "accurate." Try the following C program:
#include<stdio.h>

int main(void)
{
    int anInt = 19088743;
    float aFloat = 19088.743;

    printf("The integer is %i and the float is %f\n", anInt, aFloat);

    return 0;
}

It prints

     The integer is 19088743 and the float is 19088.742188

which doesn't even round off to 19088.743. The real question with floating point is: How many bits are required for the significand?

--Bob





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux