File: float_literals.ml

package info (click to toggle)
js-of-ocaml 6.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 37,932 kB
  • sloc: ml: 135,957; javascript: 58,364; ansic: 437; makefile: 422; sh: 12; perl: 4
file content (285 lines) | stat: -rw-r--r-- 12,708 bytes parent folder | download | duplicates (5)
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
(* TEST *)

open Printf

(* By making the field "f" mutable, we prevent the creation of structured
   constants and force the FP values to be loaded in an FP register,
   then stored in memory and passed to the "test" function. *)

type t = { mutable f : float }

let test x y =
  if Int64.bits_of_float x.f <> y then
    printf "Error: bits_of_float %h <> 0x%Lx\n" x.f y
[@@inline never]

(* The values tested include
     - those that are loaded by special x87 instructions on i386:
         +0.0, -0.0, +1.0, -1.0
     - those that are loaded by xorpd on amd64:
         +0.0;
     - those that are loaded by "fmov immediate" on arm64:
         see list below
*)
let _ =
  test { f = 0.0 } 0L;
  test { f = (-0.0) } 0x8000000000000000L;
  (* The following are the "fmov immediate" of arm64 *)
  (* They include +1.0 and -1.0 *)
  test { f = 0x1p-3 } 0x3fc0000000000000L;
  test { f = 0x1.1p-3 } 0x3fc1000000000000L;
  test { f = 0x1.2p-3 } 0x3fc2000000000000L;
  test { f = 0x1.3p-3 } 0x3fc3000000000000L;
  test { f = 0x1.4p-3 } 0x3fc4000000000000L;
  test { f = 0x1.5p-3 } 0x3fc5000000000000L;
  test { f = 0x1.6p-3 } 0x3fc6000000000000L;
  test { f = 0x1.7p-3 } 0x3fc7000000000000L;
  test { f = 0x1.8p-3 } 0x3fc8000000000000L;
  test { f = 0x1.9p-3 } 0x3fc9000000000000L;
  test { f = 0x1.ap-3 } 0x3fca000000000000L;
  test { f = 0x1.bp-3 } 0x3fcb000000000000L;
  test { f = 0x1.cp-3 } 0x3fcc000000000000L;
  test { f = 0x1.dp-3 } 0x3fcd000000000000L;
  test { f = 0x1.ep-3 } 0x3fce000000000000L;
  test { f = 0x1.fp-3 } 0x3fcf000000000000L;
  test { f = 0x1p-2 } 0x3fd0000000000000L;
  test { f = 0x1.1p-2 } 0x3fd1000000000000L;
  test { f = 0x1.2p-2 } 0x3fd2000000000000L;
  test { f = 0x1.3p-2 } 0x3fd3000000000000L;
  test { f = 0x1.4p-2 } 0x3fd4000000000000L;
  test { f = 0x1.5p-2 } 0x3fd5000000000000L;
  test { f = 0x1.6p-2 } 0x3fd6000000000000L;
  test { f = 0x1.7p-2 } 0x3fd7000000000000L;
  test { f = 0x1.8p-2 } 0x3fd8000000000000L;
  test { f = 0x1.9p-2 } 0x3fd9000000000000L;
  test { f = 0x1.ap-2 } 0x3fda000000000000L;
  test { f = 0x1.bp-2 } 0x3fdb000000000000L;
  test { f = 0x1.cp-2 } 0x3fdc000000000000L;
  test { f = 0x1.dp-2 } 0x3fdd000000000000L;
  test { f = 0x1.ep-2 } 0x3fde000000000000L;
  test { f = 0x1.fp-2 } 0x3fdf000000000000L;
  test { f = 0x1p-1 } 0x3fe0000000000000L;
  test { f = 0x1.1p-1 } 0x3fe1000000000000L;
  test { f = 0x1.2p-1 } 0x3fe2000000000000L;
  test { f = 0x1.3p-1 } 0x3fe3000000000000L;
  test { f = 0x1.4p-1 } 0x3fe4000000000000L;
  test { f = 0x1.5p-1 } 0x3fe5000000000000L;
  test { f = 0x1.6p-1 } 0x3fe6000000000000L;
  test { f = 0x1.7p-1 } 0x3fe7000000000000L;
  test { f = 0x1.8p-1 } 0x3fe8000000000000L;
  test { f = 0x1.9p-1 } 0x3fe9000000000000L;
  test { f = 0x1.ap-1 } 0x3fea000000000000L;
  test { f = 0x1.bp-1 } 0x3feb000000000000L;
  test { f = 0x1.cp-1 } 0x3fec000000000000L;
  test { f = 0x1.dp-1 } 0x3fed000000000000L;
  test { f = 0x1.ep-1 } 0x3fee000000000000L;
  test { f = 0x1.fp-1 } 0x3fef000000000000L;
  test { f = 0x1p+0 } 0x3ff0000000000000L;
  test { f = 0x1.1p+0 } 0x3ff1000000000000L;
  test { f = 0x1.2p+0 } 0x3ff2000000000000L;
  test { f = 0x1.3p+0 } 0x3ff3000000000000L;
  test { f = 0x1.4p+0 } 0x3ff4000000000000L;
  test { f = 0x1.5p+0 } 0x3ff5000000000000L;
  test { f = 0x1.6p+0 } 0x3ff6000000000000L;
  test { f = 0x1.7p+0 } 0x3ff7000000000000L;
  test { f = 0x1.8p+0 } 0x3ff8000000000000L;
  test { f = 0x1.9p+0 } 0x3ff9000000000000L;
  test { f = 0x1.ap+0 } 0x3ffa000000000000L;
  test { f = 0x1.bp+0 } 0x3ffb000000000000L;
  test { f = 0x1.cp+0 } 0x3ffc000000000000L;
  test { f = 0x1.dp+0 } 0x3ffd000000000000L;
  test { f = 0x1.ep+0 } 0x3ffe000000000000L;
  test { f = 0x1.fp+0 } 0x3fff000000000000L;
  test { f = 0x1p+1 } 0x4000000000000000L;
  test { f = 0x1.1p+1 } 0x4001000000000000L;
  test { f = 0x1.2p+1 } 0x4002000000000000L;
  test { f = 0x1.3p+1 } 0x4003000000000000L;
  test { f = 0x1.4p+1 } 0x4004000000000000L;
  test { f = 0x1.5p+1 } 0x4005000000000000L;
  test { f = 0x1.6p+1 } 0x4006000000000000L;
  test { f = 0x1.7p+1 } 0x4007000000000000L;
  test { f = 0x1.8p+1 } 0x4008000000000000L;
  test { f = 0x1.9p+1 } 0x4009000000000000L;
  test { f = 0x1.ap+1 } 0x400a000000000000L;
  test { f = 0x1.bp+1 } 0x400b000000000000L;
  test { f = 0x1.cp+1 } 0x400c000000000000L;
  test { f = 0x1.dp+1 } 0x400d000000000000L;
  test { f = 0x1.ep+1 } 0x400e000000000000L;
  test { f = 0x1.fp+1 } 0x400f000000000000L;
  test { f = 0x1p+2 } 0x4010000000000000L;
  test { f = 0x1.1p+2 } 0x4011000000000000L;
  test { f = 0x1.2p+2 } 0x4012000000000000L;
  test { f = 0x1.3p+2 } 0x4013000000000000L;
  test { f = 0x1.4p+2 } 0x4014000000000000L;
  test { f = 0x1.5p+2 } 0x4015000000000000L;
  test { f = 0x1.6p+2 } 0x4016000000000000L;
  test { f = 0x1.7p+2 } 0x4017000000000000L;
  test { f = 0x1.8p+2 } 0x4018000000000000L;
  test { f = 0x1.9p+2 } 0x4019000000000000L;
  test { f = 0x1.ap+2 } 0x401a000000000000L;
  test { f = 0x1.bp+2 } 0x401b000000000000L;
  test { f = 0x1.cp+2 } 0x401c000000000000L;
  test { f = 0x1.dp+2 } 0x401d000000000000L;
  test { f = 0x1.ep+2 } 0x401e000000000000L;
  test { f = 0x1.fp+2 } 0x401f000000000000L;
  test { f = 0x1p+3 } 0x4020000000000000L;
  test { f = 0x1.1p+3 } 0x4021000000000000L;
  test { f = 0x1.2p+3 } 0x4022000000000000L;
  test { f = 0x1.3p+3 } 0x4023000000000000L;
  test { f = 0x1.4p+3 } 0x4024000000000000L;
  test { f = 0x1.5p+3 } 0x4025000000000000L;
  test { f = 0x1.6p+3 } 0x4026000000000000L;
  test { f = 0x1.7p+3 } 0x4027000000000000L;
  test { f = 0x1.8p+3 } 0x4028000000000000L;
  test { f = 0x1.9p+3 } 0x4029000000000000L;
  test { f = 0x1.ap+3 } 0x402a000000000000L;
  test { f = 0x1.bp+3 } 0x402b000000000000L;
  test { f = 0x1.cp+3 } 0x402c000000000000L;
  test { f = 0x1.dp+3 } 0x402d000000000000L;
  test { f = 0x1.ep+3 } 0x402e000000000000L;
  test { f = 0x1.fp+3 } 0x402f000000000000L;
  test { f = 0x1p+4 } 0x4030000000000000L;
  test { f = 0x1.1p+4 } 0x4031000000000000L;
  test { f = 0x1.2p+4 } 0x4032000000000000L;
  test { f = 0x1.3p+4 } 0x4033000000000000L;
  test { f = 0x1.4p+4 } 0x4034000000000000L;
  test { f = 0x1.5p+4 } 0x4035000000000000L;
  test { f = 0x1.6p+4 } 0x4036000000000000L;
  test { f = 0x1.7p+4 } 0x4037000000000000L;
  test { f = 0x1.8p+4 } 0x4038000000000000L;
  test { f = 0x1.9p+4 } 0x4039000000000000L;
  test { f = 0x1.ap+4 } 0x403a000000000000L;
  test { f = 0x1.bp+4 } 0x403b000000000000L;
  test { f = 0x1.cp+4 } 0x403c000000000000L;
  test { f = 0x1.dp+4 } 0x403d000000000000L;
  test { f = 0x1.ep+4 } 0x403e000000000000L;
  test { f = 0x1.fp+4 } 0x403f000000000000L;
  test { f = (-0x1p-3) } 0xbfc0000000000000L;
  test { f = (-0x1.1p-3) } 0xbfc1000000000000L;
  test { f = (-0x1.2p-3) } 0xbfc2000000000000L;
  test { f = (-0x1.3p-3) } 0xbfc3000000000000L;
  test { f = (-0x1.4p-3) } 0xbfc4000000000000L;
  test { f = (-0x1.5p-3) } 0xbfc5000000000000L;
  test { f = (-0x1.6p-3) } 0xbfc6000000000000L;
  test { f = (-0x1.7p-3) } 0xbfc7000000000000L;
  test { f = (-0x1.8p-3) } 0xbfc8000000000000L;
  test { f = (-0x1.9p-3) } 0xbfc9000000000000L;
  test { f = (-0x1.ap-3) } 0xbfca000000000000L;
  test { f = (-0x1.bp-3) } 0xbfcb000000000000L;
  test { f = (-0x1.cp-3) } 0xbfcc000000000000L;
  test { f = (-0x1.dp-3) } 0xbfcd000000000000L;
  test { f = (-0x1.ep-3) } 0xbfce000000000000L;
  test { f = (-0x1.fp-3) } 0xbfcf000000000000L;
  test { f = (-0x1p-2) } 0xbfd0000000000000L;
  test { f = (-0x1.1p-2) } 0xbfd1000000000000L;
  test { f = (-0x1.2p-2) } 0xbfd2000000000000L;
  test { f = (-0x1.3p-2) } 0xbfd3000000000000L;
  test { f = (-0x1.4p-2) } 0xbfd4000000000000L;
  test { f = (-0x1.5p-2) } 0xbfd5000000000000L;
  test { f = (-0x1.6p-2) } 0xbfd6000000000000L;
  test { f = (-0x1.7p-2) } 0xbfd7000000000000L;
  test { f = (-0x1.8p-2) } 0xbfd8000000000000L;
  test { f = (-0x1.9p-2) } 0xbfd9000000000000L;
  test { f = (-0x1.ap-2) } 0xbfda000000000000L;
  test { f = (-0x1.bp-2) } 0xbfdb000000000000L;
  test { f = (-0x1.cp-2) } 0xbfdc000000000000L;
  test { f = (-0x1.dp-2) } 0xbfdd000000000000L;
  test { f = (-0x1.ep-2) } 0xbfde000000000000L;
  test { f = (-0x1.fp-2) } 0xbfdf000000000000L;
  test { f = (-0x1p-1) } 0xbfe0000000000000L;
  test { f = (-0x1.1p-1) } 0xbfe1000000000000L;
  test { f = (-0x1.2p-1) } 0xbfe2000000000000L;
  test { f = (-0x1.3p-1) } 0xbfe3000000000000L;
  test { f = (-0x1.4p-1) } 0xbfe4000000000000L;
  test { f = (-0x1.5p-1) } 0xbfe5000000000000L;
  test { f = (-0x1.6p-1) } 0xbfe6000000000000L;
  test { f = (-0x1.7p-1) } 0xbfe7000000000000L;
  test { f = (-0x1.8p-1) } 0xbfe8000000000000L;
  test { f = (-0x1.9p-1) } 0xbfe9000000000000L;
  test { f = (-0x1.ap-1) } 0xbfea000000000000L;
  test { f = (-0x1.bp-1) } 0xbfeb000000000000L;
  test { f = (-0x1.cp-1) } 0xbfec000000000000L;
  test { f = (-0x1.dp-1) } 0xbfed000000000000L;
  test { f = (-0x1.ep-1) } 0xbfee000000000000L;
  test { f = (-0x1.fp-1) } 0xbfef000000000000L;
  test { f = (-0x1p+0) } 0xbff0000000000000L;
  test { f = (-0x1.1p+0) } 0xbff1000000000000L;
  test { f = (-0x1.2p+0) } 0xbff2000000000000L;
  test { f = (-0x1.3p+0) } 0xbff3000000000000L;
  test { f = (-0x1.4p+0) } 0xbff4000000000000L;
  test { f = (-0x1.5p+0) } 0xbff5000000000000L;
  test { f = (-0x1.6p+0) } 0xbff6000000000000L;
  test { f = (-0x1.7p+0) } 0xbff7000000000000L;
  test { f = (-0x1.8p+0) } 0xbff8000000000000L;
  test { f = (-0x1.9p+0) } 0xbff9000000000000L;
  test { f = (-0x1.ap+0) } 0xbffa000000000000L;
  test { f = (-0x1.bp+0) } 0xbffb000000000000L;
  test { f = (-0x1.cp+0) } 0xbffc000000000000L;
  test { f = (-0x1.dp+0) } 0xbffd000000000000L;
  test { f = (-0x1.ep+0) } 0xbffe000000000000L;
  test { f = (-0x1.fp+0) } 0xbfff000000000000L;
  test { f = (-0x1p+1) } 0xc000000000000000L;
  test { f = (-0x1.1p+1) } 0xc001000000000000L;
  test { f = (-0x1.2p+1) } 0xc002000000000000L;
  test { f = (-0x1.3p+1) } 0xc003000000000000L;
  test { f = (-0x1.4p+1) } 0xc004000000000000L;
  test { f = (-0x1.5p+1) } 0xc005000000000000L;
  test { f = (-0x1.6p+1) } 0xc006000000000000L;
  test { f = (-0x1.7p+1) } 0xc007000000000000L;
  test { f = (-0x1.8p+1) } 0xc008000000000000L;
  test { f = (-0x1.9p+1) } 0xc009000000000000L;
  test { f = (-0x1.ap+1) } 0xc00a000000000000L;
  test { f = (-0x1.bp+1) } 0xc00b000000000000L;
  test { f = (-0x1.cp+1) } 0xc00c000000000000L;
  test { f = (-0x1.dp+1) } 0xc00d000000000000L;
  test { f = (-0x1.ep+1) } 0xc00e000000000000L;
  test { f = (-0x1.fp+1) } 0xc00f000000000000L;
  test { f = (-0x1p+2) } 0xc010000000000000L;
  test { f = (-0x1.1p+2) } 0xc011000000000000L;
  test { f = (-0x1.2p+2) } 0xc012000000000000L;
  test { f = (-0x1.3p+2) } 0xc013000000000000L;
  test { f = (-0x1.4p+2) } 0xc014000000000000L;
  test { f = (-0x1.5p+2) } 0xc015000000000000L;
  test { f = (-0x1.6p+2) } 0xc016000000000000L;
  test { f = (-0x1.7p+2) } 0xc017000000000000L;
  test { f = (-0x1.8p+2) } 0xc018000000000000L;
  test { f = (-0x1.9p+2) } 0xc019000000000000L;
  test { f = (-0x1.ap+2) } 0xc01a000000000000L;
  test { f = (-0x1.bp+2) } 0xc01b000000000000L;
  test { f = (-0x1.cp+2) } 0xc01c000000000000L;
  test { f = (-0x1.dp+2) } 0xc01d000000000000L;
  test { f = (-0x1.ep+2) } 0xc01e000000000000L;
  test { f = (-0x1.fp+2) } 0xc01f000000000000L;
  test { f = (-0x1p+3) } 0xc020000000000000L;
  test { f = (-0x1.1p+3) } 0xc021000000000000L;
  test { f = (-0x1.2p+3) } 0xc022000000000000L;
  test { f = (-0x1.3p+3) } 0xc023000000000000L;
  test { f = (-0x1.4p+3) } 0xc024000000000000L;
  test { f = (-0x1.5p+3) } 0xc025000000000000L;
  test { f = (-0x1.6p+3) } 0xc026000000000000L;
  test { f = (-0x1.7p+3) } 0xc027000000000000L;
  test { f = (-0x1.8p+3) } 0xc028000000000000L;
  test { f = (-0x1.9p+3) } 0xc029000000000000L;
  test { f = (-0x1.ap+3) } 0xc02a000000000000L;
  test { f = (-0x1.bp+3) } 0xc02b000000000000L;
  test { f = (-0x1.cp+3) } 0xc02c000000000000L;
  test { f = (-0x1.dp+3) } 0xc02d000000000000L;
  test { f = (-0x1.ep+3) } 0xc02e000000000000L;
  test { f = (-0x1.fp+3) } 0xc02f000000000000L;
  test { f = (-0x1p+4) } 0xc030000000000000L;
  test { f = (-0x1.1p+4) } 0xc031000000000000L;
  test { f = (-0x1.2p+4) } 0xc032000000000000L;
  test { f = (-0x1.3p+4) } 0xc033000000000000L;
  test { f = (-0x1.4p+4) } 0xc034000000000000L;
  test { f = (-0x1.5p+4) } 0xc035000000000000L;
  test { f = (-0x1.6p+4) } 0xc036000000000000L;
  test { f = (-0x1.7p+4) } 0xc037000000000000L;
  test { f = (-0x1.8p+4) } 0xc038000000000000L;
  test { f = (-0x1.9p+4) } 0xc039000000000000L;
  test { f = (-0x1.ap+4) } 0xc03a000000000000L;
  test { f = (-0x1.bp+4) } 0xc03b000000000000L;
  test { f = (-0x1.cp+4) } 0xc03c000000000000L;
  test { f = (-0x1.dp+4) } 0xc03d000000000000L;
  test { f = (-0x1.ep+4) } 0xc03e000000000000L;
  test { f = (-0x1.fp+4) } 0xc03f000000000000L;
  ()