~ubuntu-branches/ubuntu/trusty/emscripten/trusty-proposed

« back to all changes in this revision

Viewing changes to system/lib/libc/musl/src/math/ilogb.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2014-01-19 14:12:40 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20140119141240-jg1l42cc158j59tn
Tags: 1.9.0~20140119~7dc8c2f-1
* New snapshot release (Closes: #733714)
* Provide sources for javascript and flash. Done in orig-tar.sh
  Available in third_party/websockify/include/web-socket-js/src/
  (Closes: #735903)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <limits.h>
 
2
#include "libm.h"
 
3
 
 
4
int ilogb(double x)
 
5
{
 
6
        #pragma STDC FENV_ACCESS ON
 
7
        union {double f; uint64_t i;} u = {x};
 
8
        uint64_t i = u.i;
 
9
        int e = i>>52 & 0x7ff;
 
10
 
 
11
        if (!e) {
 
12
                i <<= 12;
 
13
                if (i == 0) {
 
14
                        FORCE_EVAL(0/0.0f);
 
15
                        return FP_ILOGB0;
 
16
                }
 
17
                /* subnormal x */
 
18
                for (e = -0x3ff; i>>63 == 0; e--, i<<=1);
 
19
                return e;
 
20
        }
 
21
        if (e == 0x7ff) {
 
22
                FORCE_EVAL(0/0.0f);
 
23
                return i<<12 ? FP_ILOGBNAN : INT_MAX;
 
24
        }
 
25
        return e - 0x3ff;
 
26
}