* print long double on Tru64 Unix5.0
@ 2000-07-12 4:00 Mickael GASTINEAU
2000-07-12 4:00 ` Mathew Hendry
2000-07-14 4:00 ` Joe Mario
0 siblings, 2 replies; 3+ messages in thread
From: Mickael GASTINEAU @ 2000-07-12 4:00 UTC (permalink / raw)
I have some trouble to print long double data on Tru64 Unix5.0A with the
system call printf(3).
After the 16th digit, it always print 0 for the digits.
But long double has about 33 significant digits on Tru64Unix5.0A.
I use the format "Le" (or LE) to specify the long double.
The compiler is Compaq C (6.1) included in Tru64 Unix5.0A.
I try to investigate with ladebug. Ladebug displays corretly the long double
number.
#include <float.h>
#include <math.h>
#include <stdio.h>
#include<malloc.h>
int main()
{
printf("sizeof(long double):%d\n",sizeof(long double));
printf("LDBL_DIG:%d\n",LDBL_DIG);
printf("max long double=%.31Le\n",LDBL_MAX);
printf("pi=%.31Le\n",atan2l(-1.0E0L,0.E0L));
}
I compile my source with the command :
cc ldbl.c -o ldbl -lm
The output is :
sizeof(long double):16
LDBL_DIG:33
max long double=1.1897314953572318000000000000000e+4932
pi=-1.5707963267948966000000000000000e+00
Mickael,
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: print long double on Tru64 Unix5.0
2000-07-12 4:00 print long double on Tru64 Unix5.0 Mickael GASTINEAU
@ 2000-07-12 4:00 ` Mathew Hendry
2000-07-14 4:00 ` Joe Mario
1 sibling, 0 replies; 3+ messages in thread
From: Mathew Hendry @ 2000-07-12 4:00 UTC (permalink / raw)
On Wed, 12 Jul 2000 21:13:38 +0200, "Mickael GASTINEAU" <amgastineau@voonoo.net>
wrote:
>I have some trouble to print long double data on Tru64 Unix5.0A with the
>system call printf(3).
>After the 16th digit, it always print 0 for the digits.
>But long double has about 33 significant digits on Tru64Unix5.0A.
>[...]
You need a better standard C library.
The simplest approach to printing a floating point number is to scale the number
by powers of 10 into the range of the largest available integer type, then to
convert that to a string, giving a decimal significand.
If you're only getting 16 decimal digits, it's probably because your library is
using a 64-bit integer for the intermediate representation. Other libraries
(e.g. glibc) use arbitrary precison integer arithmetic to give effectively
unlimited precision.
-- Mat.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: print long double on Tru64 Unix5.0
2000-07-12 4:00 print long double on Tru64 Unix5.0 Mickael GASTINEAU
2000-07-12 4:00 ` Mathew Hendry
@ 2000-07-14 4:00 ` Joe Mario
1 sibling, 0 replies; 3+ messages in thread
From: Joe Mario @ 2000-07-14 4:00 UTC (permalink / raw)
To: Mickael GASTINEAU
Mickael GASTINEAU wrote:
> I have some trouble to print long double data on Tru64 Unix5.0A with the
> system call printf(3).
> After the 16th digit, it always print 0 for the digits.
This is a known problem with the libc printf code
when printing long doubles. We should have a fix
available for the next V5.0A patch pool release.
Joe Mario
Compaq Tru64 UNIX Development Environment
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-07-14 4:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-07-12 4:00 print long double on Tru64 Unix5.0 Mickael GASTINEAU
2000-07-12 4:00 ` Mathew Hendry
2000-07-14 4:00 ` Joe Mario
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox