source: trunk/minix/lib/gnu/ieee_float/frexp.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1021 bytes
Line 
1/*
2libc/ieee_float/frexp.c
3
4Created: Oct 14, 1993 by Philip Homburg <philip@cs.vu.nl>
5
6Implementation of frexp that directly manipulates the exponent bits in an
7ieee float
8*/
9
10#include <sys/types.h>
11#include <math.h>
12
13#include "ieee_float.h"
14
15double frexp(value, eptr)
16double value;
17int *eptr;
18{
19 struct f64 *f64p;
20 int exp, exp_bias;
21 double factor;
22
23 f64p= (struct f64 *)&value;
24 exp_bias= 0;
25
26 exp= F64_GET_EXP(f64p);
27 if (exp == F64_EXP_MAX)
28 { /* Either infinity or Nan */
29 *eptr= 0;
30 return value;
31 }
32 if (exp == 0)
33 {
34 /* Either 0 or denormal */
35 if (F64_GET_MANT_LOW(f64p) == 0 &&
36 F64_GET_MANT_HIGH(f64p) == 0)
37 {
38 *eptr= 0;
39 return value;
40 }
41
42 /* Multiply by 2^64 */
43 factor= 65536.0; /* 2^16 */
44 factor *= factor; /* 2^32 */
45 factor *= factor; /* 2^64 */
46 value *= factor;
47 exp_bias= 64;
48 exp= F64_GET_EXP(f64p);
49 }
50
51 exp= exp - F64_EXP_BIAS - exp_bias + 1;
52 *eptr= exp;
53 F64_SET_EXP(f64p, F64_EXP_BIAS-1);
54
55 return value;
56}
57
58/*
59 * $PchId: frexp.c,v 1.3 1996/02/22 21:01:39 philip Exp $
60 */
Note: See TracBrowser for help on using the repository browser.