You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We can subdivide the set of all possible double precision floating point
159
-
// numbers + 64-bit (u)int numbers to eight categories:
160
-
// 1. Lossless integers: numbers that are precisely representable by both a
161
-
// double and 64-bit signed integer, and all numbers smaller in abs value are
162
-
// also precisely representable.
163
-
// I.e. numbers [-2^53, 2^53] (inclusive)
164
-
constuint64_tlosslessIntegers[] = {
165
-
0,
166
-
1,
167
-
2,
168
-
3,
169
-
0x0FFFFFFu,
170
-
0x1000000u, // == 16777216, largest consecutive single-precision floating point number
171
-
0x1000001u,
172
-
0x01020304u,
173
-
0x7FFFFFFFu,
174
-
0x80000000u,
175
-
0x90000000u,
176
-
0xFFFFFFFFu,
177
-
0x100000000ull,
178
-
0x100000001ull,
179
-
0x17FFFFFFFull,
180
-
0x180000000ull,
181
-
0xFFFFFFFFFull,
182
-
0x10203000000000ull,
183
-
0x1FFFFF00000000ull,
184
-
0x1FFFFF00000001ull,
185
-
0x1FFFFFFFFFFFFEull,
186
-
0x1FFFFFFFFFFFFFull,
187
-
0x20000000000000ull, // 9,007,199,254,740,992, largest consecutive double-precision floating point number
188
-
};
189
-
190
-
// 2. Precise integers: numbers that are precisely representable by both a
191
-
// double and 64-bit unsigned integer, but their neighboring numbers are
192
-
// not. E.g.
193
-
// E.g. 9223372036854775808 == 0x8000000000000000ull and
194
-
// 18,446,744,073,709,549,568 == 0xfffffffffffff800ull are integer numbers
195
-
// representable as both double and 64-bit uint.
196
-
constuint64_tpreciseUnsignedIntegers[] = {
197
-
0x8000000000000000ull, // 9,223,372,036,854,775,808, a number around the sign point of int64_t, representable as double
198
-
// Disabled for now, this is not converting consistently in different build modes.
199
-
//0x8000000000000800ull, // 9,223,372,036,854,777,856, a number around the sign point of int64_t, representable as double (however conversion to this is not possible due to precision issues)
200
-
0x25F5BDA103AA08ull, // 10684768937290248
201
-
0x3F3837D5442494ull, // 17794735985140884
202
-
0x55B4ACAE7DC2A0ull, // 24124026775257760
203
-
0x72BDFA99BF28A8ull, // 32297031363930280
204
-
0xA4055CD86A9F40ull, // 46167792506543936
205
-
0x125AFCA30078D10ull, // 82665451100278032
206
-
0x1268C844FE925C0ull, // 82908143057184192
207
-
0x12A1DB1454D02A0ull, // 83912190268867232
208
-
0x13E8D61ECEA80C0ull, // 89664494320124096
209
-
0x1881B7DBD49D3D0ull, // 110368417731171280
210
-
0xFE73E98A5E93F00ull, // 1145953455528558336
211
-
0x2A44DB9E56754000ull, // 3045800721111138304
212
-
0x7FFFFFFFFFFFFC00ull, // 9,223,372,036,854,774,784, a number around the sign point of int64_t, representable as double
213
-
// Disabled for now, the following do not convert consistently in different build modes.
214
-
// 0x9C04E99FFB426800ull, // 11242367443148105728
215
-
// 0xB1BEDE55F1E6B000ull, // 12807918851000283136
216
-
// 0xE762A64DFB28E800ull, // 16673071624335452160
217
-
// 0xFFFFFFFFFFFFF800ull, // 18,446,744,073,709,549,568, largest integer that is representable as both a double and a uint64_t. (however conversion to this is not possible due to precision issues) (-2048 as int64)
218
-
};
219
-
220
-
// 3. Precise negative integers: numbers that are precisely representable by
221
-
// both a double and 64-bit signed integer, but their neighboring numbers are
222
-
// not.
223
-
constint64_tpreciseNegativeIntegers[] = {
224
-
0xFFD32C4AC85FB1AEll, // -12617674251062866
225
-
0xFF3A4C372D2373A8ll, // -55648245524499544
226
-
0xFF15853220D118D0ll, // -66000169181570864
227
-
0xFE555489B4E3E2D0ll, // -120096864633363760
228
-
0xFAFD5B94D7646780ll, // -361031700292802688
229
-
0xF838033421CB9A40ll, // -560694631167452608
230
-
0xD310CE1F89FC2200ll, // -3237861497225076224
231
-
0xCA6ACDC11C161C00ll, // -3861047501233185792
232
-
0xAF6178DCAFF5A800ll, // -5809229155090978816
233
-
0x9AFE3153D877A400ll, // -7278325711600376832
234
-
0x8B7B357A4C942C00ll, // -8396058280915096576
235
-
};
236
-
237
-
// 4. Imprecise unsigned integers: Numbers representable by a 64-bit uint, but
238
-
// not representable in a double, so a rounding error occurs with uint64_t
239
-
// -> double -> uint64_t conversion.
240
-
// I.e. numbers [2^53+1, 2^64-1] for uint64 that are not representable as a
241
-
// double. E.g. 0xffffffffffffffffull == 18,446,744,073,709,551,615 cannot
0 commit comments