Skip to content

Commit 988acd6

Browse files
authored
Merge pull request #77 from JuliaMath/jq/1.0
Fixes for 1.0
2 parents f7d7921 + 7ea28e4 commit 988acd6

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ deps/installed_vers
55
deps/libbid*.*
66
deps/deps.jl
77
deps/usr
8+
deps/build.log

Diff for: src/DecFP.jl

+7-2
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ for w in (32,64,128)
413413
for c in (, :e, :ℯ, , :catalan, )
414414
@eval begin
415415
Base.convert(::Type{$BID}, ::Irrational{$(QuoteNode(c))}) = $(_parse(T, setprecision(256) do
416-
string(BigFloat(isdefined(Base, :MathConstants) ? Core.eval(Base.MathConstants, c) : eval(c)))
416+
string(BigFloat(getfield(Compat.MathConstants, c)))
417417
end))
418418
end
419419
end
@@ -502,13 +502,18 @@ end
502502
const pinf128 = _parse(Dec128, "+Inf")
503503
const minf128 = _parse(Dec128, "-Inf")
504504

505-
for T in (Dec32,Dec64,Dec128)
505+
for T in (Dec32, Dec64, Dec128)
506506
@eval begin
507507
Base.eps(::Type{$T}) = $(_sub(_nextfloat(one(T)), one(T)))
508508
Base.typemax(::Type{$T}) = $(_parse(T, "+inf"))
509509
Base.typemin(::Type{$T}) = $(_parse(T, "-inf"))
510+
@static if isdefined(Base, :floatmax)
511+
Base.floatmax(::Type{$T}) = $(_prevfloat(_parse(T, "+inf")))
512+
Base.floatmin(::Type{$T}) = $(_nextfloat(zero(T)))
513+
else
510514
Base.realmax(::Type{$T}) = $(_prevfloat(_parse(T, "+inf")))
511515
Base.realmin(::Type{$T}) = $(_nextfloat(zero(T)))
516+
end
512517
end
513518
end
514519

Diff for: test/runtests.jl

+14-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ if VERSION >= v"0.7.0-alpha.69"
88
using SpecialFunctions
99
end
1010

11+
if !isdefined(Base, :floatmax)
12+
floatmax(x) = realmax(x)
13+
floatmin(x) = realmin(x)
14+
end
15+
1116

1217
@test unsafe_load(DecFP.flags[]) == 0
1318

@@ -20,21 +25,21 @@ for T in (Dec32, Dec64, Dec128)
2025
if T == Dec32
2126
@test d32"3.2" * d32"4.5" == d32"14.4"
2227
@test eps(Dec32) == parse(Dec32, "1e-6")
23-
@test realmax(Dec32) == parse(Dec32, "+9999999E+90")
24-
@test realmin(Dec32) == parse(Dec32, "+1E-101")
28+
@test floatmax(Dec32) == parse(Dec32, "+9999999E+90")
29+
@test floatmin(Dec32) == parse(Dec32, "+1E-101")
2530
@test bswap(Dec32(1.5)) == reinterpret(Dec32, bswap(reinterpret(UInt32, Dec32(1.5))))
2631
elseif T == Dec64
2732
@test d"3.2" * d"4.5" == d"14.4"
2833
@test d64"3.2" * d64"4.5" == d64"14.4"
2934
@test eps(Dec64) == parse(Dec64, "1e-15")
30-
@test realmax(Dec64) == parse(Dec64, "+9999999999999999E+369")
31-
@test realmin(Dec64) == parse(Dec64, "+1E-398")
35+
@test floatmax(Dec64) == parse(Dec64, "+9999999999999999E+369")
36+
@test floatmin(Dec64) == parse(Dec64, "+1E-398")
3237
@test bswap(Dec64(1.5)) == reinterpret(Dec64, bswap(reinterpret(UInt64, Dec64(1.5))))
3338
else
3439
@test d128"3.2" * d128"4.5" == d128"14.4"
3540
@test eps(Dec128) == parse(Dec128, "1e-33")
36-
@test realmax(Dec128) == parse(Dec128, "+9999999999999999999999999999999999E+6111")
37-
@test realmin(Dec128) == parse(Dec128, "+1E-6176")
41+
@test floatmax(Dec128) == parse(Dec128, "+9999999999999999999999999999999999E+6111")
42+
@test floatmin(Dec128) == parse(Dec128, "+1E-6176")
3843
@test bswap(Dec128(1.5)) == reinterpret(Dec128, bswap(reinterpret(UInt128, Dec128(1.5))))
3944
end
4045

@@ -172,9 +177,9 @@ for T in (Dec32, Dec64, Dec128)
172177
@test round(Ti, T(2.5), RoundNearestTiesAway) === round(Ti, T(3.3), RoundNearestTiesAway) === Ti(3)
173178
@test round(Ti, T(2.5), RoundNearestTiesUp) === round(Ti, T(3.3), RoundNearestTiesUp) === Ti(3)
174179
@test_throws InexactError convert(Ti, xd)
175-
@test_throws InexactError trunc(Ti, realmax(T))
176-
@test_throws InexactError floor(Ti, realmax(T))
177-
@test_throws InexactError ceil(Ti, realmax(T))
180+
@test_throws InexactError trunc(Ti, floatmax(T))
181+
@test_throws InexactError floor(Ti, floatmax(T))
182+
@test_throws InexactError ceil(Ti, floatmax(T))
178183
if Ti <: Signed
179184
@test parse(T, "-17") == T(Ti(-17)) == Ti(-17) == Ti(T(-17))
180185
end

0 commit comments

Comments
 (0)