Subject: Re: libc ieee math cleanup
To: Simon Burge <simonb@wasabisystems.com>
From: David Laight <dsl@l8s.co.uk>
List: tech-userlevel
Date: 02/11/2002 17:32:26
On Tue, Feb 12, 2002 at 02:22:04AM +1100, Simon Burge wrote:
> 
> The following diff is a clean up some of the rampant code duplication in
> libc.  The following functions
> 
> 	libc/gen/ieee754_frexp.c
> 	libc/gen/ieee754_isinf.c
> 	libc/gen/ieee754_isnan.c
> 	libc/gen/ieee754_ldexp.c
> 	libc/gen/ieee754_modf.c
> 
> and constants are added
> 
> 	libc/gen/ieee754_infinity.c
> 	libc/gen/ieee754_nanf.c
> 

I haven't looked at the old defns for these routunes, but were they
global before?  If not the names need rather more '_' and all the 'weak'
defintion.  (Maybe ansi prototypes?)
> +/*
> + * Split the given value into a fraction in the range [0.5, 1.0) and
> + * an exponent, such that frac * (2^exp) == value.  If value is 0,
> + * return 0.
> + */
> +double
> +frexp(value, eptr)
> +	double value;
> +	int *eptr;
> +{

The definition below isn't correct for the standard ARM format for double
numbers - which would normally be little endian 32bit words, MS word first
ie { 0, 0, 0xf0, 0x7f, 0, 0, 0 ,0 }
(don't ask me who decided on that byte ordering!).
I hope we don't have a massive FP cock-up for ARM?

> +const union __double_u __infinity =
> +#if BYTE_ORDER == BIG_ENDIAN
> +	{ { 0x7f, 0xf0, 0, 0, 0, 0,    0,    0} };
> +#else
> +	{ {    0,    0, 0, 0, 0, 0, 0xf0, 0x7f} };
> +#endif

	David