@@ -2,28 +2,29 @@ using FixedPointNumbers
22using Base. Test
33using Compat
44
5- @test reinterpret (0xa2 uf8) == 0xa2
6- @test reinterpret (0xa2 uf10) == 0xa2
7- @test reinterpret (0xa2 uf12) == 0xa2
8- @test reinterpret (0xa2 uf14) == 0xa2
9- @test reinterpret (0xa2 uf16) == 0xa2
10-
11- @test reinterpret (N0f8, 0xa2 ) == 0xa2 uf8
12- @test reinterpret (N6f10, 0x1fa2 ) == 0x1fa2 uf10
13- @test reinterpret (N4f12, 0x1fa2 ) == 0x1fa2 uf12
14- @test reinterpret (N2f14, 0x1fa2 ) == 0x1fa2 uf14
15- @test reinterpret (N0f16, 0x1fa2 ) == 0x1fa2 uf16
5+ @test reinterpret (N0f8, 0xa2 ). i === 0xa2
6+ @test reinterpret (N6f10, 0x1fa2 ). i === 0x1fa2
7+ @test reinterpret (N4f12, 0x1fa2 ). i === 0x1fa2
8+ @test reinterpret (N2f14, 0x1fa2 ). i === 0x1fa2
9+ @test reinterpret (N0f16, 0x1fa2 ). i === 0x1fa2
10+
11+ @test reinterpret (reinterpret (N0f8, 0xa2 )) === 0xa2
12+ @test reinterpret (reinterpret (N6f10, 0x00a2 )) === 0x00a2
13+ @test reinterpret (reinterpret (N4f12, 0x00a2 )) === 0x00a2
14+ @test reinterpret (reinterpret (N2f14, 0x00a2 )) === 0x00a2
15+ @test reinterpret (reinterpret (N0f16, 0x00a2 )) === 0x00a2
16+
1617@test 0.635 N0f8 == N0f8 (0.635 )
1718@test 0.635 N6f10 == N6f10 (0.635 )
1819@test 0.635 N4f12 == N4f12 (0.635 )
1920@test 0.635 N2f14 == N2f14 (0.635 )
2021@test 0.635 N0f16 == N0f16 (0.635 )
2122
22- @test N0f8 (1.0 ) == 0xff uf8
23- @test N0f8 (0.5 ) == 0x80 uf8
24- @test N2f14 (1.0 ) == 0x3fff uf14
23+ @test N0f8 (1.0 ) == reinterpret (N0f8, 0xff )
24+ @test N0f8 (0.5 ) == reinterpret (N0f8, 0x80 )
25+ @test N2f14 (1.0 ) == reinterpret (N2f14, 0x3fff )
2526v = @compat N4f12 .([2 ])
26- @test v == N4f12[0x1ffe uf12 ]
27+ @test v == N4f12[reinterpret (N4f12, 0x1ffe ) ]
2728@test isa (v, Vector{N4f12})
2829
2930UF2 = (UFixed{UInt32,16 }, UFixed{UInt64,3 }, UFixed{UInt64,51 }, UFixed{UInt128,7 }, UFixed{UInt128,51 })
114115
115116x = N0f8 (0b01010001 , 0 )
116117@test ~ x == N0f8 (0b10101110 , 0 )
117- @test - x == 0xaf uf8
118+ @test - x == reinterpret (N0f8, 0xaf )
118119
119120@test isa (float (one (UFixed{UInt8,7 })), Float32)
120121@test isa (float (one (UFixed{UInt32,18 })), Float64)
@@ -192,16 +193,16 @@ end
192193@test ! (N0f8 (0.5 ) < N0f8 (0.5 ))
193194@test N0f8 (0.5 ) <= N0f8 (0.5 )
194195
195- @test div (0x10 uf8, 0x02 uf8) == fld (0x10 uf8, 0x02 uf8 ) == 8
196- @test div (0x0f uf8, 0x02 uf8) == fld (0x0f uf8, 0x02 uf8 ) == 7
197- @test Base. fld1 (0x10 uf8, 0x02 uf8 ) == 8
198- @test Base. fld1 (0x0f uf8, 0x02 uf8 ) == 8
199- @test mod (0x10 uf8, 0x02 uf8) == rem (0x10 uf8, 0x02 uf8 ) == 0
200- @test mod (0x0f uf8, 0x02 uf8) == rem (0x0f uf8, 0x02 uf8) == 0x01 uf8
201- @test mod1 (0x10 uf8, 0x02 uf8) == 0x02 uf8
202- @test mod1 (0x0f uf8, 0x02 uf8) == 0x01 uf8
196+ @test div (reinterpret (N0f8, 0x10 ), reinterpret (N0f8, 0x02 )) == fld (reinterpret (N0f8, 0x10 ), reinterpret (N0f8, 0x02 ) ) == 8
197+ @test div (reinterpret (N0f8, 0x0f ), reinterpret (N0f8, 0x02 )) == fld (reinterpret (N0f8, 0x0f ), reinterpret (N0f8, 0x02 ) ) == 7
198+ @test Base. fld1 (reinterpret (N0f8, 0x10 ), reinterpret (N0f8, 0x02 ) ) == 8
199+ @test Base. fld1 (reinterpret (N0f8, 0x0f ), reinterpret (N0f8, 0x02 ) ) == 8
200+ @test mod (reinterpret (N0f8, 0x10 ), reinterpret (N0f8, 0x02 )) == rem (reinterpret (N0f8, 0x10 ), reinterpret (N0f8, 0x02 ) ) == 0
201+ @test mod (reinterpret (N0f8, 0x0f ), reinterpret (N0f8, 0x02 )) == rem (reinterpret (N0f8, 0x0f ), reinterpret (N0f8, 0x02 )) == reinterpret (N0f8, 0x01 )
202+ @test mod1 (reinterpret (N0f8, 0x10 ), reinterpret (N0f8, 0x02 )) == reinterpret (N0f8, 0x02 )
203+ @test mod1 (reinterpret (N0f8, 0x0f ), reinterpret (N0f8, 0x02 )) == reinterpret (N0f8, 0x01 )
203204
204- r = 1 uf8 : 1 uf8 : 48 uf8
205+ r = reinterpret (N0f8, 0x01 ) : reinterpret (N0f8, 0x01 ) : reinterpret (N0f8, convert (UInt8, 48 ))
205206@test length (r) == 48
206207
207208counter = 0
235236@test promote_type (Float32,N0f8,Int) == Float32
236237
237238# Show
238- x = 0xaa uf8
239+ x = reinterpret (N0f8, 0xaa )
239240iob = IOBuffer ()
240241show (iob, x)
241242str = takebuf_string (iob)
@@ -269,7 +270,7 @@ generic_scale!(rfixed, ad, b)
269270@test rfloat == rfixed
270271
271272# reductions
272- a = N0f8[0xff uf8, 0xff uf8 ]
273+ a = N0f8[reinterpret (N0f8, 0xff ), reinterpret (N0f8, 0xff ) ]
273274@test sum (a) == 2.0
274275@test sum (a, 1 ) == [2.0 ]
275276
0 commit comments