@@ -255,22 +255,22 @@ end
255
255
256
256
@testset " 128-bit conversion correctness" begin
257
257
# Force the bits for these tests
258
- FD2 = FixedDecimal{Int64, 2 }
259
- UFD2 = FixedDecimal{UInt64, 2 }
258
+ F64D2 = FixedDecimal{Int64, 2 }
259
+ UF64D2 = FixedDecimal{UInt64, 2 }
260
260
261
261
@testset " Convert from 64-bit to 128-bit" begin
262
262
@test convert (WFD2, 1 ). i === Int128 (100 )
263
263
@test convert (UWFD2, 1 ). i === UInt128 (100 )
264
264
@test convert (WFD2, - 1 ). i === Int128 (- 100 )
265
265
@test_throws InexactError (:convert , UWFD2, - 1 ) convert (UWFD2, - 1 )
266
- @test convert (WFD2, UInt (1 )). i === Int128 (100 )
267
- @test convert (UWFD2, UInt (1 )). i === UInt128 (100 )
268
- @test convert (WFD2, typemax (Int )). i === Int128 (922337203685477580700 )
269
- @test convert (UWFD2, typemax (Int )). i === UInt128 (922337203685477580700 )
270
- @test convert (WFD2, typemin (Int )). i === Int128 (- 922337203685477580800 )
271
- @test_throws InexactError (:convert , UWFD2, typemin (Int )) convert (UWFD2, typemin (Int ))
272
- @test convert (WFD2, typemax (UInt )). i === Int128 (1844674407370955161500 )
273
- @test convert (UWFD2, typemax (UInt )). i === UInt128 (1844674407370955161500 )
266
+ @test convert (WFD2, UInt64 (1 )). i === Int128 (100 )
267
+ @test convert (UWFD2, UInt64 (1 )). i === UInt128 (100 )
268
+ @test convert (WFD2, typemax (Int64 )). i === Int128 (922337203685477580700 )
269
+ @test convert (UWFD2, typemax (Int64 )). i === UInt128 (922337203685477580700 )
270
+ @test convert (WFD2, typemin (Int64 )). i === Int128 (- 922337203685477580800 )
271
+ @test_throws InexactError (:convert , UWFD2, typemin (Int64 )) convert (UWFD2, typemin (Int64 ))
272
+ @test convert (WFD2, typemax (UInt64 )). i === Int128 (1844674407370955161500 )
273
+ @test convert (UWFD2, typemax (UInt64 )). i === UInt128 (1844674407370955161500 )
274
274
end
275
275
276
276
@testset " Convert from 128-bit to 128-bit" begin
@@ -289,18 +289,18 @@ end
289
289
end
290
290
291
291
@testset " Convert from 128-bit to 64-bit" begin
292
- @test convert (FD2 , Int128 (1 )). i === Int (100 )
293
- @test convert (UFD2 , Int128 (1 )). i === UInt (100 )
294
- @test convert (FD2 , UInt128 (1 )). i === Int (100 )
295
- @test convert (UFD2 , UInt128 (1 )). i === UInt (100 )
296
- @test convert (FD2 , Int128 (- 1 )). i === Int (- 100 )
297
- @test_throws InexactError (:convert , UFD2 , Int128 (- 1 )) convert (UFD2, Int128 (- 1 ))
298
- @test_throws InexactError (:convert , FD2 , typemax (Int128)) convert (FD2 , typemax (Int128))
299
- @test_throws InexactError (:convert , UFD2 , typemax (Int128)) convert (UFD2 , typemax (Int128))
300
- @test_throws InexactError (:convert , FD2 , typemin (Int128)) convert (FD2 , typemin (Int128))
301
- @test_throws InexactError (:convert , UFD2 , typemin (Int128)) convert (UFD2 , typemin (Int128))
302
- @test_throws InexactError (:convert , FD2 , typemax (UInt128)) convert (FD2 , typemax (UInt128))
303
- @test_throws InexactError (:convert , UFD2 , typemax (UInt128)) convert (UFD2 , typemax (UInt128))
292
+ @test convert (F64D2 , Int128 (1 )). i === Int64 (100 )
293
+ @test convert (UF64D2 , Int128 (1 )). i === UInt64 (100 )
294
+ @test convert (F64D2 , UInt128 (1 )). i === Int64 (100 )
295
+ @test convert (UF64D2 , UInt128 (1 )). i === UInt64 (100 )
296
+ @test convert (F64D2 , Int128 (- 1 )). i === Int64 (- 100 )
297
+ @test_throws InexactError (:convert , UF64D2 , Int128 (- 1 )) convert (UFD2, Int128 (- 1 ))
298
+ @test_throws InexactError (:convert , F64D2 , typemax (Int128)) convert (F64D2 , typemax (Int128))
299
+ @test_throws InexactError (:convert , UF64D2 , typemax (Int128)) convert (UF64D2 , typemax (Int128))
300
+ @test_throws InexactError (:convert , F64D2 , typemin (Int128)) convert (F64D2 , typemin (Int128))
301
+ @test_throws InexactError (:convert , UF64D2 , typemin (Int128)) convert (UF64D2 , typemin (Int128))
302
+ @test_throws InexactError (:convert , F64D2 , typemax (UInt128)) convert (F64D2 , typemax (UInt128))
303
+ @test_throws InexactError (:convert , UF64D2 , typemax (UInt128)) convert (UF64D2 , typemax (UInt128))
304
304
end
305
305
306
306
@testset " Convert from BigInt to 128-bit" begin
@@ -333,19 +333,16 @@ using FixedPointDecimals
333
333
334
334
const SFD2 = FixedDecimal{Int16, 2 }
335
335
const SFD4 = FixedDecimal{Int16, 4 }
336
- const FD1 = FixedDecimal{Int, 1 }
337
- const FD2 = FixedDecimal{Int, 2 }
338
- const FD3 = FixedDecimal{Int, 3 }
339
- const FD4 = FixedDecimal{Int, 4 }
336
+ const F64D2 = FixedDecimal{Int64, 2 }
337
+ const UF64D2 = FixedDecimal{UInt64, 2 }
340
338
const WFD2 = FixedDecimal{Int128, 2 }
341
- const WFD4 = FixedDecimal{Int128, 4 }
342
339
const UFD2 = FixedDecimal{UInt, 2 }
343
340
const UWFD2 = FixedDecimal{UInt128, 2 }
344
341
345
342
@testset " 128-bit conversion performance" begin
346
343
# Baseline cases
347
- @test @allocated (convert (FD2 , Int8 (- 1 ))) == 0
348
- @test @allocated (convert (FD2 , UInt8 (1 ))) == 0
344
+ @test @allocated (convert (F64D2 , Int8 (- 1 ))) == 0
345
+ @test @allocated (convert (F64D2 , UInt8 (1 ))) == 0
349
346
@test @allocated (convert (SFD2, Int8 (- 1 ))) == 0
350
347
351
348
# Int 128 cases
@@ -363,11 +360,11 @@ const UWFD2 = FixedDecimal{UInt128, 2}
363
360
@test @allocated (convert (UWFD2, UInt128 (1 ))) == 0
364
361
@test @allocated (convert (WFD2, Int128 (- 1 ))) == 0
365
362
366
- @test @allocated (convert (FD2 , Int128 (1 ))) == 0
367
- @test @allocated (convert (UFD2 , Int128 (1 ))) == 0
368
- @test @allocated (convert (FD2 , UInt128 (1 ))) == 0
369
- @test @allocated (convert (UFD2 , UInt128 (1 ))) == 0
370
- @test @allocated (convert (FD2 , Int128 (- 1 ))) == 0
363
+ @test @allocated (convert (F64D2 , Int128 (1 ))) == 0
364
+ @test @allocated (convert (UF64D2 , Int128 (1 ))) == 0
365
+ @test @allocated (convert (F64D2 , UInt128 (1 ))) == 0
366
+ @test @allocated (convert (UF64D2 , UInt128 (1 ))) == 0
367
+ @test @allocated (convert (F64D2 , Int128 (- 1 ))) == 0
371
368
end
372
369
373
370
@testset " BigInt conversion performance" begin
0 commit comments