Skip to content

Commit ec6bffe

Browse files
authored
Merge pull request #50 from stevengj/jq/0.7
0.7 updates
2 parents 6584924 + f113663 commit ec6bffe

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/DecFP.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export Dec32, Dec64, Dec128, @d_str, @d32_str, @d64_str, @d128_str
33

44
const libbid = joinpath(dirname(@__FILE__), "..", "deps", "libbid$(Sys.WORD_SIZE)")
55

6-
const _buffer = Vector{UInt8}(1024)
6+
const _buffer = fill(0x00, 1024)
77

88
import Base.promote_rule
99
import Base.Grisu.DIGITS
@@ -71,11 +71,11 @@ function isnanstr(s::AbstractString)
7171
c, i = next(s, i)
7272
done(s, i) && return false
7373
end
74-
lowercase(c) == 'n' || return false
74+
(c == 'n' || c == 'N') || return false
7575
c, i = next(s, i)
76-
(!done(s, i) && lowercase(c) == 'a') || return false
76+
(!done(s, i) && (c == 'a' || c == 'A')) || return false
7777
c, i = next(s, i)
78-
(done(s, i) && lowercase(c) == 'n') || return false
78+
(done(s, i) && (c == 'n' || c == 'N')) || return false
7979
return true
8080
end
8181

@@ -229,7 +229,7 @@ for w in (32,64,128)
229229
for c in (, :e, , :catalan, )
230230
@eval begin
231231
Base.convert(::Type{$BID}, ::Irrational{$(QuoteNode(c))}) = $(_parse(T, setprecision(256) do
232-
string(BigFloat(eval(c)))
232+
string(BigFloat(isdefined(Base, :MathConstants) ? eval(Base.MathConstants, c) : eval(c)))
233233
end))
234234
end
235235
end
@@ -250,25 +250,25 @@ for w in (32,64,128)
250250
if w′ <= 64
251251
FP′ = Symbol(string("Float",w′))
252252
@eval promote_rule(::Type{$BID}, ::Type{$FP′}) = $(Symbol(string("Dec",max(w,w′))))
253-
for i′ in ("Int$w′", "UInt$w′")
253+
for (i′, i′str) in (("Int$w′", "int$w′"), ("UInt$w′", "uint$w′"))
254254
Ti′ = eval(Symbol(i′))
255255
@eval begin
256-
Base.convert(::Type{$BID}, x::$Ti′) = nox(ccall(($(bidsym(w,"from_",lowercase(i′))), libbid), $BID, ($Ti′,), x))
256+
Base.convert(::Type{$BID}, x::$Ti′) = nox(ccall(($(bidsym(w,"from_",i′str)), libbid), $BID, ($Ti′,), x))
257257
end
258258
end
259259
end
260260
end
261261

262262
for w′ in (8,16,32,64)
263-
for i′ in ("Int$w′", "UInt$w′")
263+
for (i′, i′str) in (("Int$w′", "int$w′"), ("UInt$w′", "uint$w′"))
264264
Ti′ = eval(Symbol(i′))
265265
@eval begin
266-
Base.trunc(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",lowercase(i′),"_xint")), libbid), $Ti′, ($BID,), x), InexactError, :trunc, $BID, x, mask=INVALID | OVERFLOW)
267-
Base.floor(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",lowercase(i′),"_xfloor")), libbid), $Ti′, ($BID,), x), InexactError, :floor, $BID, x, mask=INVALID | OVERFLOW)
268-
Base.ceil(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",lowercase(i′),"_xceil")), libbid), $Ti′, ($BID,), x), InexactError, :ceil, $BID, x, mask=INVALID | OVERFLOW)
269-
Base.round(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",lowercase(i′),"_xrnint")), libbid), $Ti′, ($BID,), x), InexactError, :round, $BID, x, mask=INVALID | OVERFLOW)
270-
Base.round(::Type{$Ti′}, x::$BID, ::RoundingMode{:NearestTiesAway}) = xchk(ccall(($(bidsym(w,"to_",lowercase(i′),"_xrninta")), libbid), $Ti′, ($BID,), x), InexactError, :round, $BID, x, mask=INVALID | OVERFLOW)
271-
Base.convert(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",lowercase(i′),"_xfloor")), libbid), $Ti′, ($BID,), x), InexactError, :convert, $BID, x)
266+
Base.trunc(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",i′str,"_xint")), libbid), $Ti′, ($BID,), x), InexactError, :trunc, $BID, x, mask=INVALID | OVERFLOW)
267+
Base.floor(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",i′str,"_xfloor")), libbid), $Ti′, ($BID,), x), InexactError, :floor, $BID, x, mask=INVALID | OVERFLOW)
268+
Base.ceil(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",i′str,"_xceil")), libbid), $Ti′, ($BID,), x), InexactError, :ceil, $BID, x, mask=INVALID | OVERFLOW)
269+
Base.round(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",i′str,"_xrnint")), libbid), $Ti′, ($BID,), x), InexactError, :round, $BID, x, mask=INVALID | OVERFLOW)
270+
Base.round(::Type{$Ti′}, x::$BID, ::RoundingMode{:NearestTiesAway}) = xchk(ccall(($(bidsym(w,"to_",i′str,"_xrninta")), libbid), $Ti′, ($BID,), x), InexactError, :round, $BID, x, mask=INVALID | OVERFLOW)
271+
Base.convert(::Type{$Ti′}, x::$BID) = xchk(ccall(($(bidsym(w,"to_",i′str,"_xfloor")), libbid), $Ti′, ($BID,), x), InexactError, :convert, $BID, x)
272272
end
273273
end
274274
end

0 commit comments

Comments
 (0)