diff options
author | Joakim Tjernlund <joakim.tjernlund@transmode.se> | 2007-03-31 13:28:15 +0000 |
---|---|---|
committer | Joakim Tjernlund <joakim.tjernlund@transmode.se> | 2007-03-31 13:28:15 +0000 |
commit | e7bcf43b6440ac9fc61a0eef5591393810daafb5 (patch) | |
tree | b72c3fb15e030b47b2eb02d13169b4548382e855 /libm/powerpc/classic/s_ldexp.c | |
parent | 7a40ba19c86e4d2fc7e35f14a0e629ee843b96a9 (diff) |
From Steve Papacharalambous:
Add math support for PowerPC e500.
Diffstat (limited to 'libm/powerpc/classic/s_ldexp.c')
-rw-r--r-- | libm/powerpc/classic/s_ldexp.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libm/powerpc/classic/s_ldexp.c b/libm/powerpc/classic/s_ldexp.c new file mode 100644 index 000000000..10100d7c2 --- /dev/null +++ b/libm/powerpc/classic/s_ldexp.c @@ -0,0 +1,49 @@ +/******************************************************************************* +* * +* File frexpldexp.c, * +* Functions frexp(x) and ldexp(x), * +* Implementation of frexp and ldexp functions for the PowerPC. * +* * +* Copyright © 1991 Apple Computer, Inc. All rights reserved. * +* * +* Written by Ali Sazegari, started on January 1991, * +* * +* W A R N I N G: This routine expects a 64 bit double model. * +* * +* December03 1992: first rs6000 implementation. * +* October 05 1993: added special cases for NaN and ° in frexp. * +* May 27 1997: improved the performance of frexp by eliminating the * +* switch statement. * +* June 13 2001: (ram) rewrote frexp to eliminate calls to scalb and * +* logb. * +* * +*******************************************************************************/ + +#include <limits.h> +#include <math.h> +#include <endian.h> + +typedef union + { + struct { +#if (__BYTE_ORDER == __BIG_ENDIAN) + unsigned long int hi; + unsigned long int lo; +#else + unsigned long int lo; + unsigned long int hi; +#endif + } words; + double dbl; + } DblInHex; + +libm_hidden_proto(ldexp) +double ldexp ( double value, int exp ) + { + if ( exp > SHRT_MAX ) + exp = SHRT_MAX; + else if ( exp < -SHRT_MAX ) + exp = -SHRT_MAX; + return scalb ( value, exp ); + } +libm_hidden_def(ldexp) |