Skip to content

Commit 30b6c9b

Browse files
RalphASsimonbyrne
authored andcommitted
clean up irrational conversions (#41)
1 parent 6572522 commit 30b6c9b

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Quadmath"
22
uuid = "be4d8f0f-7fa4-5f49-b795-2f01399ab2dd"
3-
version = "0.5.1"
3+
version = "0.5.2-DEV"
44

55
[compat]
66
julia = "1.0"

src/Quadmath.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,8 @@ function nextfloat(f::Float128, d::Integer)
446446
end
447447

448448
Float128(::Irrational{:π}) = reinterpret(Float128, 0x4000921fb54442d18469898cc51701b8)
449-
Float128(::Irrational{:e}) = reinterpret(Float128, 0x40005bf0a8b1457695355fb8ac404e7a)
449+
Float128(::Irrational{:ℯ}) = reinterpret(Float128, 0x40005bf0a8b1457695355fb8ac404e7a)
450+
Float128(x::Irrational{T}) where {T} = Float128(BigFloat(x))
450451

451452
import Base.MPFR
452453

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ end
173173
@test parse(Float128,"3.0") == Float128(3.0)
174174
end
175175

176+
@testset "irrationals" begin
177+
tiny = 2eps(Float128(1))
178+
@test abs(cos(Float128(pi)) + 1) < tiny
179+
@test abs(log(Float128(ℯ)) - 1) < tiny
180+
@test abs((2*Float128(MathConstants.golden) - 1)^2 - 5) < 5 * tiny
181+
end
182+
176183
include("specfun.jl")
177184

178185
include("printf.jl")

0 commit comments

Comments
 (0)