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) ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) : __fpclassifyd(x))
16#define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) : __signbitd(x))
17#define isfinite(x) ((fpclassify(x) > 2))
18
19#define __signbitf(x) ((int)(__HI(x) & 0x80000000))
20
21// TODO: OK?
22#define __signbitd(x) ((int)(__HI(x) & 0x80000000))
23
24extern unsigned long __float_nan[];
25extern unsigned long __float_huge[];
26extern unsigned long __float_max[];
27extern unsigned long __float_epsilon[];
28
29inline int __fpclassifyf(float __value) {
30 unsigned long integer = *(unsigned long*)&__value;
31
32 switch (integer & 0x7f800000) {
33 case 0x7f800000:
34 if ((integer & 0x7fffff) != 0) {
35 return FP_QNAN;
36 }
37 return FP_INFINITE;
38
39 case 0:
40 if ((integer & 0x7fffff) != 0) {
41 return FP_SUBNORMAL;
42 }
43 return FP_ZERO;
44 }
45
46 return FP_NORMAL;
47}
48
49inline int __fpclassifyd(double __value) {
50 switch (__HI(__value) & 0x7ff00000) {
51 case 0x7ff00000: {
52 if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff))
53 return FP_QNAN;
54 else
55 return FP_INFINITE;
56 break;
57 }
58 case 0: {
59 if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff))
60 return FP_SUBNORMAL;
61 else
62 return FP_ZERO;
63 break;
64 }
65 }
66 return FP_NORMAL;
67}
68
69#define FLT_MANT_DIG 24
70#define FLT_DIG 6
71#define FLT_MIN_EXP (-125)
72#define FLT_MIN_10_EXP (-37)
73#define FLT_MAX_EXP 128
74#define FLT_MAX_10_EXP 38
75
76#define FLT_MAX (*(float*) __float_max)
77#define FLT_EPSILON (*(float*) __float_epsilon)
78
79#define DBL_MANT_DIG 53
80#define DBL_DIG 15
81#define DBL_MIN_EXP (-1021)
82#define DBL_MIN_10_EXP (-308)
83#define DBL_MAX_EXP 1024
84#define DBL_MAX_10_EXP 308
85
86#endif /* _MSL_COMMON_FLOAT_H */
T cLib_calcTimer(T *value)
Definition c_lib.h:74
__LO(df)=0
__HI(x)
int __fpclassifyf(float __value)
Definition float.h:29
unsigned long __float_huge[]
Definition float.c:7
int __fpclassifyd(double __value)
Definition float.h:49
unsigned long __float_epsilon[]
Definition float.c:13
unsigned long __float_max[]
Definition float.c:10
unsigned long __float_nan[]
Definition float.c:4