Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4921 Serge 1
/*
2
 * compute 10**x by successive squaring.
3
 */
4
 
5
#include <_ansi.h>
6
#include "std.h"
7
 
8
double
9
_DEFUN (__exp10, (x),
10
	unsigned x)
11
{
12
  static _CONST double powtab[] =
13
  {1.0,
14
   10.0,
15
   100.0,
16
   1000.0,
17
   10000.0};
18
 
19
  if (x < (sizeof (powtab) / sizeof (double)))
20
      return powtab[x];
21
  else if (x & 1)
22
    {
23
      return 10.0 * __exp10 (x - 1);
24
    }
25
  else
26
    {
27
      double n = __exp10 (x / 2);
28
      return n * n;
29
    }
30
}