@@ -2,28 +2,29 @@ using FixedPointNumbers
2
2
using Base. Test
3
3
using Compat
4
4
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
+
16
17
@test 0.635 N0f8 == N0f8 (0.635 )
17
18
@test 0.635 N6f10 == N6f10 (0.635 )
18
19
@test 0.635 N4f12 == N4f12 (0.635 )
19
20
@test 0.635 N2f14 == N2f14 (0.635 )
20
21
@test 0.635 N0f16 == N0f16 (0.635 )
21
22
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 )
25
26
v = @compat N4f12 .([2 ])
26
- @test v == N4f12[0x1ffe uf12 ]
27
+ @test v == N4f12[reinterpret (N4f12, 0x1ffe ) ]
27
28
@test isa (v, Vector{N4f12})
28
29
29
30
UF2 = (UFixed{UInt32,16 }, UFixed{UInt64,3 }, UFixed{UInt64,51 }, UFixed{UInt128,7 }, UFixed{UInt128,51 })
114
115
115
116
x = N0f8 (0b01010001 , 0 )
116
117
@test ~ x == N0f8 (0b10101110 , 0 )
117
- @test - x == 0xaf uf8
118
+ @test - x == reinterpret (N0f8, 0xaf )
118
119
119
120
@test isa (float (one (UFixed{UInt8,7 })), Float32)
120
121
@test isa (float (one (UFixed{UInt32,18 })), Float64)
@@ -192,16 +193,16 @@ end
192
193
@test ! (N0f8 (0.5 ) < N0f8 (0.5 ))
193
194
@test N0f8 (0.5 ) <= N0f8 (0.5 )
194
195
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 )
203
204
204
- r = 1 uf8 : 1 uf8 : 48 uf8
205
+ r = reinterpret (N0f8, 0x01 ) : reinterpret (N0f8, 0x01 ) : reinterpret (N0f8, convert (UInt8, 48 ))
205
206
@test length (r) == 48
206
207
207
208
counter = 0
235
236
@test promote_type (Float32,N0f8,Int) == Float32
236
237
237
238
# Show
238
- x = 0xaa uf8
239
+ x = reinterpret (N0f8, 0xaa )
239
240
iob = IOBuffer ()
240
241
show (iob, x)
241
242
str = takebuf_string (iob)
@@ -269,7 +270,7 @@ generic_scale!(rfixed, ad, b)
269
270
@test rfloat == rfixed
270
271
271
272
# reductions
272
- a = N0f8[0xff uf8, 0xff uf8 ]
273
+ a = N0f8[reinterpret (N0f8, 0xff ), reinterpret (N0f8, 0xff ) ]
273
274
@test sum (a) == 2.0
274
275
@test sum (a, 1 ) == [2.0 ]
275
276
0 commit comments