Mail Archives: djgpp/1996/08/25/01:53:54
On Fri, 23 Aug 1996, Detsoury Ngonvorarath wrote:
> void main(void)
> {
> printf("%lg\n", sin(1));
> }
>
> $ gcc -o a01 a01.c -lm
>
> With djgpp 1.12 under msdos 6.2 :
> $ go32 a01
> 0.8414709848079
>
> With djgpp 2 under win 95, the output is truncated :
> $ go32-v2 a01
> 0.841471
>
> What must I do to get the correct result 0.8414709848079 with djgpp 2 ?
That's easy. Just say this:
printf ("%18.14g\n", sin(1.0));
(Note that you don't need to use `lg' in a printf, `g' is enough.)
Morale: if you want to see a certain number of significant digits in a
floating-point number, never trust the library to do it for you, always
request this explicitly.
- Raw text -