source: trunk/libs/newlib/src/newlib/libc/stdlib/__exp10.c @ 543

Last change on this file since 543 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 414 bytes
Line 
1/*
2 * compute 10**x by successive squaring.
3 */
4
5#include <_ansi.h>
6#include "std.h"
7
8double
9__exp10 (unsigned x)
10{
11  static const double powtab[] =
12  {1.0,
13   10.0,
14   100.0,
15   1000.0,
16   10000.0};
17
18  if (x < (sizeof (powtab) / sizeof (double)))
19      return powtab[x];
20  else if (x & 1)
21    {
22      return 10.0 * __exp10 (x - 1);
23    }
24  else
25    {
26      double n = __exp10 (x / 2);
27      return n * n;
28    }
29}
Note: See TracBrowser for help on using the repository browser.