Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4973 right-hear 1
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
2
#include 
3
 
4
double
5
frexp(double x, int *exptr)
6
{
7
  union {
8
    double d;
9
    unsigned char c[8];
10
  } u;
11
 
12
  u.d = x;
13
  /*
14
   * The format of the number is:
15
   * Sign, 12 exponent bits, 51 mantissa bits
16
   * The exponent is 1023 biased and there is an implicit zero.
17
   * We get the exponent from the upper bits and set the exponent
18
   * to 0x3fe (1022).
19
   */
20
  *exptr = (int)(((u.c[7] & 0x7f) << 4) | (u.c[6] >> 4)) - 1022;
21
  u.c[7] &= 0x80;
22
  u.c[7] |= 0x3f;
23
  u.c[6] &= 0x0f;
24
  u.c[6] |= 0xe0;
25
  return u.d;
26
}