forked from rui314/chibicc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
float.c
93 lines (79 loc) · 2.16 KB
/
float.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
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
#include "test.h"
int main() {
ASSERT(35, (float)(char)35);
ASSERT(35, (float)(short)35);
ASSERT(35, (float)(int)35);
ASSERT(35, (float)(long)35);
ASSERT(35, (float)(unsigned char)35);
ASSERT(35, (float)(unsigned short)35);
ASSERT(35, (float)(unsigned int)35);
ASSERT(35, (float)(unsigned long)35);
ASSERT(35, (double)(char)35);
ASSERT(35, (double)(short)35);
ASSERT(35, (double)(int)35);
ASSERT(35, (double)(long)35);
ASSERT(35, (double)(unsigned char)35);
ASSERT(35, (double)(unsigned short)35);
ASSERT(35, (double)(unsigned int)35);
ASSERT(35, (double)(unsigned long)35);
ASSERT(35, (char)(float)35);
ASSERT(35, (short)(float)35);
ASSERT(35, (int)(float)35);
ASSERT(35, (long)(float)35);
ASSERT(35, (unsigned char)(float)35);
ASSERT(35, (unsigned short)(float)35);
ASSERT(35, (unsigned int)(float)35);
ASSERT(35, (unsigned long)(float)35);
ASSERT(35, (char)(double)35);
ASSERT(35, (short)(double)35);
ASSERT(35, (int)(double)35);
ASSERT(35, (long)(double)35);
ASSERT(35, (unsigned char)(double)35);
ASSERT(35, (unsigned short)(double)35);
ASSERT(35, (unsigned int)(double)35);
ASSERT(35, (unsigned long)(double)35);
ASSERT(-2147483648, (double)(unsigned long)(long)-1);
ASSERT(1, 2e3==2e3);
ASSERT(0, 2e3==2e5);
ASSERT(1, 2.0==2);
ASSERT(0, 5.1<5);
ASSERT(0, 5.0<5);
ASSERT(1, 4.9<5);
ASSERT(0, 5.1<=5);
ASSERT(1, 5.0<=5);
ASSERT(1, 4.9<=5);
ASSERT(1, 2e3f==2e3);
ASSERT(0, 2e3f==2e5);
ASSERT(1, 2.0f==2);
ASSERT(0, 5.1f<5);
ASSERT(0, 5.0f<5);
ASSERT(1, 4.9f<5);
ASSERT(0, 5.1f<=5);
ASSERT(1, 5.0f<=5);
ASSERT(1, 4.9f<=5);
ASSERT(6, 2.3+3.8);
ASSERT(-1, 2.3-3.8);
ASSERT(-3, -3.8);
ASSERT(13, 3.3*4);
ASSERT(2, 5.0/2);
ASSERT(6, 2.3f+3.8f);
ASSERT(6, 2.3f+3.8);
ASSERT(-1, 2.3f-3.8);
ASSERT(-3, -3.8f);
ASSERT(13, 3.3f*4);
ASSERT(2, 5.0f/2);
ASSERT(0, 0.0/0.0 == 0.0/0.0);
ASSERT(1, 0.0/0.0 != 0.0/0.0);
ASSERT(0, 0.0/0.0 < 0);
ASSERT(0, 0.0/0.0 <= 0);
ASSERT(0, 0.0/0.0 > 0);
ASSERT(0, 0.0/0.0 >= 0);
ASSERT(0, !3.);
ASSERT(1, !0.);
ASSERT(0, !3.f);
ASSERT(1, !0.f);
ASSERT(5, 0.0 ? 3 : 5);
ASSERT(3, 1.2 ? 3 : 5);
printf("OK\n");
return 0;
}