this repo has no description
1
2/*
3 * fpclassify.c
4 *
5 * by Ian Ollmann
6 *
7 * Copyright (c) 2007, Apple Inc. All Rights Reserved.
8 *
9 * C99 implementation for __fpclassify function (called by FPCLASSIFY macro.)
10 */
11
12#include "math.h"
13#include <stdint.h>
14
15int __fpclassify( double x )
16{
17 union{ double d; uint64_t u;}u = {x};
18
19 uint32_t exp = (uint32_t) ( (u.u & 0x7fffffffffffffffULL) >> 52 );
20
21 if( 0 == exp )
22 {
23 if( u.u & 0x000fffffffffffffULL )
24 return FP_SUBNORMAL;
25
26 return FP_ZERO;
27 }
28
29 if( 0x7ff == exp )
30 {
31 if( u.u & 0x000fffffffffffffULL )
32 return FP_NAN;
33
34 return FP_INFINITE;
35 }
36
37 return FP_NORMAL;
38}