diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2000-12-14 00:25:06 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2000-12-14 00:25:06 +0000 |
commit | b6182a09dd286f592f2968c324cb2ce36f5b9082 (patch) | |
tree | d5fe53f33018bfa8b1194c5165e815aea1cee9ae /newlib/libc/stdlib/ldtoa.c | |
parent | adbbb0348ccebe74a0dbb93307a6d3f96b757fc0 (diff) | |
download | newlib-b6182a09dd286f592f2968c324cb2ce36f5b9082.zip newlib-b6182a09dd286f592f2968c324cb2ce36f5b9082.tar.gz newlib-b6182a09dd286f592f2968c324cb2ce36f5b9082.tar.bz2 |
2000-12-13 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/ldtoa.c (_ldcheck): New routine
that categorizes a long double as NaN, Infinity, or other.
* libc/stdio/vfprintf.c [WANT_IO_LONG_DBL](_VFPRINTF_R): Removed
isinfl and isnanl static routines which were i386-specific. Changed
calls to the two removed routines to a single _ldcheck call.
* libc/stdio/vfieeefp.h (ldieee): Fixed missing semi-colons.
Diffstat (limited to 'newlib/libc/stdlib/ldtoa.c')
-rw-r--r-- | newlib/libc/stdlib/ldtoa.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/newlib/libc/stdlib/ldtoa.c b/newlib/libc/stdlib/ldtoa.c index 046e939..b332d2a 100644 --- a/newlib/libc/stdlib/ldtoa.c +++ b/newlib/libc/stdlib/ldtoa.c @@ -13,6 +13,7 @@ /* linux name: long double _IO_strtold (char *, char **); */ long double _strtold (char *, char **); char * _ldtoa_r (struct _reent *, long double, int, int, int *, int *, char **); +int _ldcheck (long double *); #if 0 void _IO_ldtostr(long double *, char *, int, int, char); #endif @@ -2826,6 +2827,46 @@ if( rve ) return outstr; } +/* Routine used to tell if long double is NaN or Infinity or regular number. + Returns: 0 = regular number + 1 = Nan + 2 = Infinity +*/ +int +_ldcheck (long double *d) +{ +unsigned short e[NI]; +char *s, *p; +int k; +LDPARMS rnd; +LDPARMS *ldp = &rnd; +char *outstr; + +rnd.rlast = -1; +rnd.rndprc = NBITS; + +#if LDBL_MANT_DIG == 24 +e24toe( (unsigned short *)d, e, ldp ); +#elif LDBL_MANT_DIG == 53 +e53toe( (unsigned short *)d, e, ldp ); +#elif LDBL_MANT_DIG == 64 +e64toe( (unsigned short *)d, e, ldp ); +#else +e113toe( (unsigned short *)d, e, ldp ); +#endif + +if( (e[NE-1] & 0x7fff) == 0x7fff ) + { +#ifdef NANS + if( eisnan(e) ) + return( 1 ); +#endif + return( 2 ); + } +else + return( 0 ); +} /* _ldcheck */ + static void etoasc(short unsigned int *x, char *string, int ndigits, int outformat, LDPARMS *ldp) { long digit; |