1 /*******************************************************************************
4 * Functions frexp(x) and ldexp(x), *
5 * Implementation of frexp and ldexp functions for the PowerPC. *
7 * Copyright © 1991 Apple Computer, Inc. All rights reserved. *
9 * Written by Ali Sazegari, started on January 1991, *
11 * W A R N I N G: This routine expects a 64 bit double model. *
13 * December03 1992: first rs6000 implementation. *
14 * October 05 1993: added special cases for NaN and ° in frexp. *
15 * May 27 1997: improved the performance of frexp by eliminating the *
17 * June 13 2001: (ram) rewrote frexp to eliminate calls to scalb and *
20 *******************************************************************************/
26 static const double two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
31 #if (__BYTE_ORDER == __BIG_ENDIAN)
42 libm_hidden_proto(frexp)
43 double frexp ( double value, int *eptr )
46 unsigned long int valueHead;
49 valueHead = argument.words.hi & 0x7fffffffUL; // valueHead <- |x|
52 if ( valueHead >= 0x7ff00000 || ( valueHead | argument.words.lo ) == 0 )
53 return value; // 0, inf, or NaN
55 if ( valueHead < 0x00100000 )
57 argument.dbl = two54 * value;
58 valueHead = argument.words.hi &0x7fffffff;
61 *eptr += ( valueHead >> 20 ) - 1022;
62 argument.words.hi = ( argument.words.hi & 0x800fffff ) | 0x3fe00000;
65 libm_hidden_def(frexp)