OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libm/] [mathfp/] [sf_frexp.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
 
2
/* @(#)z_frexpf.c 1.0 98/08/13 */
3
/******************************************************************
4
 * frexp
5
 *
6
 * Input:
7
 *   d   - floating point value
8
 *   exp - exponent value
9
 *
10
 * Output:
11
 *   A floating point value in the range [0.5, 1).
12
 *
13
 * Description:
14
 *   This routine breaks a floating point value into a number f and
15
 *   an exponent exp such that d = f * 2 ^ exp.
16
 *
17
 *****************************************************************/
18
 
19
#include "fdlibm.h"
20
#include "zmath.h"
21
 
22
float frexpf (float d, int *exp)
23
{
24
  float f;
25
  __int32_t wf, wd;
26
 
27
  GET_FLOAT_WORD (wd, d);
28
 
29
  /* Get the exponent. */
30
  *exp = ((wd & 0x7f800000) >> 23) - 126;
31
 
32
  /* Get the mantissa. */
33
  wf = wd & 0x7fffff;
34
  wf |= 0x3f000000;
35
 
36
  SET_FLOAT_WORD (f, wf);
37
 
38
  /* Check for special values. */
39
  switch (numtestf (f))
40
    {
41
      case NAN:
42
      case INF:
43
        errno = EDOM;
44
        *exp = 0;
45
        return (f);
46
    }
47
 
48
  return (f);
49
}
50
 
51
#ifdef _DOUBLE_IS_32BITS
52
 
53
double frexp (double x, int *exp)
54
{
55
  return (double) frexpf ((float) x, exp);
56
}
57
 
58
#endif /* defined(_DOUBLE_IS_32BITS) */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.