Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
float.h
Go to the documentation of this file.
1#ifndef _MSL_COMMON_FLOAT_H
2#define _MSL_COMMON_FLOAT_H
3
4#include "fdlibm.h"
5
6#define FP_SNAN 0
7#define FP_QNAN 1
8#define FP_INFINITE 2
9#define FP_ZERO 3
10#define FP_NORMAL 4
11#define FP_SUBNORMAL 5
12
13#define FP_NAN FP_QNAN
14
15#define fpclassify(x) \
16 ((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : \
17 (sizeof(x) == sizeof(double)) ? __fpclassifyd((double)(x)) : \
18 __fpclassifyl((long double)(x)) )
19#define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) : __signbitd(x))
20#define isfinite(x) ((fpclassify(x) > FP_INFINITE))
21#define isnan(x) (fpclassify(x) == FP_NAN)
22#define isinf(x) (fpclassify(x) == FP_INFINITE)
23
24#define __signbitf(x) ((int)(__HI(x) & 0x80000000))
25
26// TODO: OK?
27#define __signbitd(x) ((int)(__HI(x) & 0x80000000))
28
29extern unsigned long __float_nan[];
30extern unsigned long __float_huge[];
31extern unsigned long __float_max[];
32extern unsigned long __float_epsilon[];
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38inline int __fpclassifyf(float __value) {
39 unsigned long integer = *(unsigned long*)&__value;
40
41 switch (integer & 0x7f800000) {
42 case 0x7f800000:
43 if ((integer & 0x7fffff) != 0) {
44 return FP_QNAN;
45 }
46 return FP_INFINITE;
47
48 case 0:
49 if ((integer & 0x7fffff) != 0) {
50 return FP_SUBNORMAL;
51 }
52 return FP_ZERO;
53 }
54
55 return FP_NORMAL;
56}
57
58inline int __fpclassifyd(double __value) {
59 switch (__HI(__value) & 0x7ff00000) {
60 case 0x7ff00000: {
61 if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff))
62 return FP_QNAN;
63 else
64 return FP_INFINITE;
65 break;
66 }
67 case 0: {
68 if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff))
69 return FP_SUBNORMAL;
70 else
71 return FP_ZERO;
72 break;
73 }
74 }
75 return FP_NORMAL;
76}
77
78// Stripped function.
79int __fpclassifyl(long double __value);
80
81#ifdef __cplusplus
82}; // extern "C"
83#endif
84
85#define FLT_MANT_DIG 24
86#define FLT_DIG 6
87#define FLT_MIN_EXP (-125)
88#define FLT_MIN_10_EXP (-37)
89#define FLT_MAX_EXP 128
90#define FLT_MAX_10_EXP 38
91
92#if DEBUG
93#define FLT_MAX 3.4028235e38f
94#define FLT_EPSILON 1.1920929e-7f
95#else
96#define FLT_MAX (*(float*) __float_max)
97#define FLT_EPSILON (*(float*) __float_epsilon)
98#endif
99
100#define DBL_MANT_DIG 53
101#define DBL_DIG 15
102#define DBL_MIN_EXP (-1021)
103#define DBL_MIN_10_EXP (-308)
104#define DBL_MAX_EXP 1024
105#define DBL_MAX_10_EXP 308
106
107#endif /* _MSL_COMMON_FLOAT_H */
__LO(df)=0
__HI(x)
int __fpclassifyf(float __value)
Definition float.h:38
int __fpclassifyl(long double __value)
unsigned long __float_huge[]
Definition float.c:5
int __fpclassifyd(double __value)
Definition float.h:58
unsigned long __float_epsilon[]
Definition float.c:9
unsigned long __float_max[]
Definition float.c:7
unsigned long __float_nan[]
Definition float.c:3