Pavel Pokorny
2005-11-24 09:00:23 UTC
Dear gcc friends,
can you, please, help me
to use a 16 byte long double precision (35 decimal digits)?
It looks like a 10 byte (18 digits) precision
on my AMD Opteron hp xw9300 workstation
although sizeof reports 16 bytes!
#include<stdio.h>
int main()
{
int i;
long double x,dx=0.1,x0=2;
for (i=1;i<20;i++){
dx = dx/10;
x = x0 + dx;
x = x - x0;
(void) printf ("i=%d x=%LG\n",i,x);
};
(void) printf (" sizeof(x) = %d \n", (int)sizeof(x));
}
i=1 x=0.01
i=2 x=0.001
i=3 x=0.0001
i=4 x=1E-05
i=5 x=1E-06
i=6 x=1E-07
i=7 x=1E-08
i=8 x=1E-09
i=9 x=1E-10
i=10 x=1E-11
i=11 x=1E-12
i=12 x=1E-13
i=13 x=1E-14
i=14 x=1.00007E-15
i=15 x=9.99634E-17
i=16 x=9.97466E-18
i=17 x=1.0842E-18
i=18 x=0
i=19 x=0
sizeof(x) = 16
gcc (GCC) 3.4.4 20050721 (Red Hat 3.4.4-2)
Linux 2.6.9-22.EL #1 Mon Sep 19 17:49:49 EDT 2005 x86_64 x86_64 x86_64
Thanks for any advice.
can you, please, help me
to use a 16 byte long double precision (35 decimal digits)?
It looks like a 10 byte (18 digits) precision
on my AMD Opteron hp xw9300 workstation
although sizeof reports 16 bytes!
#include<stdio.h>
int main()
{
int i;
long double x,dx=0.1,x0=2;
for (i=1;i<20;i++){
dx = dx/10;
x = x0 + dx;
x = x - x0;
(void) printf ("i=%d x=%LG\n",i,x);
};
(void) printf (" sizeof(x) = %d \n", (int)sizeof(x));
}
i=1 x=0.01
i=2 x=0.001
i=3 x=0.0001
i=4 x=1E-05
i=5 x=1E-06
i=6 x=1E-07
i=7 x=1E-08
i=8 x=1E-09
i=9 x=1E-10
i=10 x=1E-11
i=11 x=1E-12
i=12 x=1E-13
i=13 x=1E-14
i=14 x=1.00007E-15
i=15 x=9.99634E-17
i=16 x=9.97466E-18
i=17 x=1.0842E-18
i=18 x=0
i=19 x=0
sizeof(x) = 16
gcc (GCC) 3.4.4 20050721 (Red Hat 3.4.4-2)
Linux 2.6.9-22.EL #1 Mon Sep 19 17:49:49 EDT 2005 x86_64 x86_64 x86_64
Thanks for any advice.
--
Pavel Pokorny
Math Dept, Prague Institute of Chemical Technology
http://www.vscht.cz/mat/Pavel.Pokorny
Pavel Pokorny
Math Dept, Prague Institute of Chemical Technology
http://www.vscht.cz/mat/Pavel.Pokorny