Skip to content

Commit d20c4f8

Browse files
JeffreySarnoffsimonbyrne
authored andcommitted
test BigInt, flipsign, modf (#14)
1 parent 9d446dd commit d20c4f8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/runtests.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,33 @@ end
2121
@test Float64(x+y) == Float64(BigFloat(x) + BigFloat(y))
2222
@test x+y == Float128(BigFloat(x) + BigFloat(y))
2323
end
24+
25+
@testset "BigInt" begin
26+
x = parse(Float128, "100.0")
27+
y = parse(Float128, "25.0")
28+
@test Float64(x+y) == Float64(BigInt(x) + BigInt(y))
29+
@test x+y == Float128(BigInt(x) + BigInt(y))
30+
end
31+
32+
@testset "flipsign" begin
33+
x = Float128( 2.0)
34+
y = Float128(-2.0)
35+
@test x == flipsign(y, -one(Float128))
36+
@test y == flipsign(y, 1)
37+
end
38+
39+
@testset "modf" begin
40+
x = Float128(pi)
41+
fpart, ipart = modf(x)
42+
@test x == ipart + fpart
43+
@test signbit(fpart) == signbit(ipart) == false
44+
45+
y = Float128(-pi)
46+
fpart, ipart = modf(y)
47+
@test y == ipart + fpart
48+
@test signbit(fpart) == signbit(ipart) == true
49+
50+
z = x^3
51+
fpart, ipart = modf(x) .+ modf(y)
52+
@test x+y == ipart+fpart
53+
end

0 commit comments

Comments
 (0)