reading about the ansi standard, typically doubles only support 15
significant digits. The error occurs at the 16th digit (in the C code):

8.400000e+00
8.40000000000000568434188608080148696899414062500000e+00
8.40000000000000568434188608080148696899414062500000e+00
sizeof doubles 8
sizeof long doubles 16

fp.c
······
#include <stdio.h>
#include <math.h>

int main(){
        double cien = 100.0;
        double frac = 91.6;
        long double ciento = 100.0;
        long double fract = 91.6;
        printf("%e\n", cien - frac);
        printf("%.50e\n", cien - frac);
        printf("%.50Le\n", ciento - fract);

        printf("sizeof doubles %d\n", sizeof(cien));
        printf("sizeof long doubles %d\n", sizeof(ciento));
        return 0;
}

it's a little interesting that long double is in fact twice the length
of the double but the precision is the same. It should be 19 digits,
given the 15 for the double and their cell sizes.

-- 
Luid: floating point operations seems not to match specification
https://bugs.launchpad.net/bugs/586087
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to