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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [stdlib/] [__adjust.c] - Blame information for rev 148

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * return (*acc) scaled by 10**dexp.
3
 */
4
 
5
#include <_ansi.h>
6
#include <reent.h>
7
#include "std.h"
8
 
9
#define abs(x) (((x) < 0) ? -(x) : (x))
10
 
11
double
12
_DEFUN (__adjust, (ptr, acc, dexp, sign),
13
        struct _reent *ptr _AND
14
        double *acc _AND
15
        int dexp _AND
16
        int sign)
17
     /* *acc    the 64 bit accumulator */
18
     /* dexp    decimal exponent       */
19
     /* sign    sign flag              */
20
{
21
  double r;
22
 
23
  if (dexp > MAXE)
24
    {
25
      ptr->_errno = ERANGE;
26
      return (sign) ? -HUGE_VAL : HUGE_VAL;
27
    }
28
  else if (dexp < MINE)
29
    {
30
      ptr->_errno = ERANGE;
31
      return 0.0;
32
    }
33
 
34
  r = *acc;
35
  if (sign)
36
    r = -r;
37
  if (dexp == 0)
38
    return r;
39
 
40
  if (dexp < 0)
41
    return r / __exp10 (abs (dexp));
42
  else
43
    return r * __exp10 (dexp);
44
}

powered by: WebSVN 2.1.0

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