~ubuntu-branches/ubuntu/trusty/musl/trusty-proposed

« back to all changes in this revision

Viewing changes to src/math/scalbn.c

  • Committer: Package Import Robot
  • Author(s): Kevin Bortis
  • Date: 2013-09-20 20:54:14 UTC
  • Revision ID: package-import@ubuntu.com-20130920205414-5b61trtmma18w58o
Tags: upstream-0.9.13
ImportĀ upstreamĀ versionĀ 0.9.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "libm.h"
 
2
 
 
3
double scalbn(double x, int n)
 
4
{
 
5
        double scale;
 
6
 
 
7
        if (n > 1023) {
 
8
                x *= 0x1p1023;
 
9
                n -= 1023;
 
10
                if (n > 1023) {
 
11
                        x *= 0x1p1023;
 
12
                        n -= 1023;
 
13
                        if (n > 1023)
 
14
                                n = 1023;
 
15
                }
 
16
        } else if (n < -1022) {
 
17
                x *= 0x1p-1022;
 
18
                n += 1022;
 
19
                if (n < -1022) {
 
20
                        x *= 0x1p-1022;
 
21
                        n += 1022;
 
22
                        if (n < -1022)
 
23
                                n = -1022;
 
24
                }
 
25
        }
 
26
        INSERT_WORDS(scale, (uint32_t)(0x3ff+n)<<20, 0);
 
27
        STRICT_ASSIGN(double, x, x * scale);
 
28
        return x;
 
29
}