-
Notifications
You must be signed in to change notification settings - Fork 160
/
float_h.c
67 lines (62 loc) · 1.52 KB
/
float_h.c
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
/*
* # float.h
*
* Gives characteristics of floating point numbers and of base numerical operations
* for the current architecture
*
* All macros that start with FLT have versions starting with:
*
* - DBL for `double`
* - LDBL for `long double`
*/
#include "common.h"
int main(void) {
/* # FLT_ROUNDS
*
* Rounding method of sums.
*
* Values:
*
* - -1: indeterminable
* - 0: toward zero
* - 1: to nearest
* - 2: toward positive infinity
* - 3: toward negative infinity
*
* TODO can it be changed?
*/
{
printf("FLT_ROUNDS = %d\n", FLT_ROUNDS);
}
/* # FLT_MIN
*
* Smalles positive number closest to zero that can be represented in a normal float.
*
* Any number with absolute value smaller than this is subnormal,
* and support is optional.
*/
{
printf("FLT_MIN = %a\n", FLT_MIN);
printf("DBL_MIN = %a\n", DBL_MIN);
printf("LDBL_MIN = %La\n", LDBL_MIN);
}
/* # FLT_RADIX
*
* Radix of the mantissa.
*
* TODO wow, there are non radix 2 representation implementations?!
* IEEE 754 specifies the 2015-hardware-lowly-implemented radix 10,
* maybe that is the major motivation?
*
* # FLT_MANT_DIG
*
* Number of digits bits for the mantissa:
*
* - 24 on 32-bit float
*/
{
printf("FLT_RADIX = %d\n", FLT_RADIX);
printf("FLT_MANT_DIG = %d\n", FLT_MANT_DIG);
}
return EXIT_SUCCESS;
}