-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfloat.h
More file actions
127 lines (105 loc) · 3.44 KB
/
float.h
File metadata and controls
127 lines (105 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*********************************************************************/
/* */
/* This Program Written by Paul Edwards. */
/* Released to the Public Domain */
/* */
/*********************************************************************/
/*********************************************************************/
/* */
/* float.h - float header file. */
/* */
/*********************************************************************/
#ifndef __FLOAT_INCLUDED
#define __FLOAT_INCLUDED
#if defined(__CMS__) || defined(__MVS__)
/*
IBM 360 & 370 use "HEX" floating point
float is 32 bits, double & long double are 64 bit.
Although some models can do 128 bit (actually 120 bit)
GCC does not implement this and "long double" is same as "double"
*/
/* rounding direction is unpredictable */
#define FLT_ROUNDS 0
/* Floating point is HEX so RADIX is base 16 */
#define FLT_RADIX 16
/* Note FLT_RADIX is 16 these are smaller than normal*/
#define FLT_MANT_DIG 6
#define DBL_MANT_DIG 14
/* don't use 128 bit floats so this is still 14 */
#define LDBL_MANT_DIG 14
/* As IBM uses hex float with "wobbling precision" these are approximate */
#define FLT_DIG 7
#define DBL_DIG 15
#define LDBL_DIG 15
#define FLT_MIN_EXP (-64)
#define DBL_MIN_EXP (-64)
#define LDBL_MIN_EXP (-64)
#define FLT_MIN_10_EXP (-78)
#define DBL_MIN_10_EXP (-78)
#define LDBL_MIN_10_EXP (-78)
#define FLT_MAX_EXP 63
#define DBL_MAX_EXP 63
#define LDBL_MAX_EXP 63
#define FLT_MAX_10_EXP 75
#define DBL_MAX_10_EXP 75
#define LDBL_MAX_10_EXP 75
/*
This is a temporary fiddle to get round bug in GCC
scanning of ASCII to Floats.
*/
typedef union {
unsigned short _HexVal[4];
double _Dval;
float _Fval;
long _Lval;
} _HexFloat;
static _HexFloat _FltMax = {{0x7fff, 0xffff, 0xffff, 0xffff}};
static _HexFloat _FltMin = {{0x0010, 0x0000, 0x0000, 0x0000}};
static _HexFloat _DblMax = {{0x7fff, 0xffff, 0xffff, 0xffff}};
static _HexFloat _DblMin = {{0x0010, 0x0000, 0x0000, 0x0000}};
static _HexFloat _FltEps = {{0x3C10, 0x0000, 0x0000, 0x0000}};
static _HexFloat _DblEps = {{0x3410, 0x0000, 0x0000, 0x0000}};
#define FLT_MAX _FltMax._Fval
#define DBL_MAX _DblMax._Dval
#define LDBL_MAX _DblMax._Lval
#define FLT_MIN _FltMin._Fval
#define DBL_MIN _DblMin._Fval
#define LDBL_MIN _DblMin._Fval
#define FLT_EPSILON _FltEps._Fval
#define DBL_EPSILON _DblEps._Fval
#define LDBL_EPSILON _DblEps._Fval
#else
/*
original stuff from Paul for IEEE maths
*/
#define FLT_ROUNDS 1
#define FLT_RADIX 2
#define FLT_MANT_DIG 24
#define DBL_MANT_DIG 53
#define LDBL_MANT_DIG 53
#define FLT_DIG 6
#define DBL_DIG 10
#define LDBL_DIG 10
#define FLT_MIN_EXP -125
#define DBL_MIN_EXP -1021
#define LDBL_MIN_EXP -1021
#define FLT_MIN_10_EXP -37
#define DBL_MIN_10_EXP -37
#define LDBL_MIN_10_EXP -37
#define FLT_MAX_EXP +128
#define DBL_MAX_EXP +1024
#define LDBL_MAX_EXP +1024
#define FLT_MAX_10_EXP +37
#define DBL_MAX_10_EXP +37
#define LDBL_MAX_10_EXP +37
#define FLT_MAX 1E+37
#define DBL_MAX 1E+37
#define LDBL_MAX 1E+37
#define FLT_EPSILON 1E-5
#define DBL_EPSILON 1E-9
#define LDBL_EPSILON 1E-9
#define FLT_MIN 1E-37
#define DBL_MIN 1E-37
#define LDBL_MIN 1E-37
#endif
#endif