@@ -6,6 +6,7 @@ using Test, BFloat16s, Printf, Random
6
6
@test Base. exponent_bits (BFloat16) == 8
7
7
@test Base. significand_bits (BFloat16) == 7
8
8
@test precision (BFloat16) == 8
9
+ @test Base. uinttype (BFloat16) == UInt16
9
10
10
11
@test typemin (BFloat16) == - BFloat16s. InfB16
11
12
@test typemax (BFloat16) == BFloat16s. InfB16
33
34
end
34
35
35
36
@testset " trunc" begin
36
- bf_val = 5.5
37
+ bf_val = BFloat16 ( 5.5 )
37
38
@testset " $Ti " for Ti in (Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128)
38
39
@test trunc (Ti, bf_val) == Ti (5 )
39
40
end
48
49
@test Float32 (BFloat16 (10 )) == 1f1
49
50
@test Float64 (BFloat16 (10 )) == 10.0
50
51
@test Int32 (BFloat16 (10 )) == Int32 (10 )
52
+ @test UInt32 (BFloat16 (10 )) == Int32 (10 )
51
53
@test Int64 (BFloat16 (10 )) == Int64 (10 )
54
+ @test UInt64 (BFloat16 (10 )) == Int64 (10 )
52
55
@test BFloat16 (BigFloat (1 )) == BFloat16 (1 )
53
56
@test BigFloat (BFloat16 (1 )) == BigFloat (1 )
54
57
@test Float16 (BFloat16 (3.140625 )) == Float16 (π)
55
58
@test BFloat16 (Float16 (π)) == BFloat16 (3.140625 )
56
59
60
+ @test promote (BFloat16 (4.5 ), Float64 (5.0 )) == (Float64 (4.5 ), Float64 (5.0 ))
61
+ @test promote (BFloat16 (4.5 ), Float32 (5.0 )) == (Float32 (4.5 ), Float32 (5.0 ))
62
+
57
63
@test_throws InexactError Int8 (BFloat16 (500 ))
58
64
@test_throws InexactError UInt8 (BFloat16 (500 ))
59
65
end
0 commit comments