Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2931312

Browse files
committedMar 13, 2015
fix compile error?
1 parent 59e6cdb commit 2931312

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed
 

‎base/string.jl

+20-7
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,8 @@ function tryparse_internal{T<:Integer}(::Type{T}, s::AbstractString, base::Int,
15511551
end
15521552

15531553
base = convert(T,base)
1554-
m::T = div(typemax(T)-base+1,base)
1554+
#m::T = div(typemax(T)-base+1,base)
1555+
m::T = ((T===UInt128 || T===Int128) && (Base.WORD_SIZE < 64)) ? typemax(T) : div(typemax(T)-base+1,base)
15551556
n::T = 0
15561557
while n <= m
15571558
d::T = '0' <= c <= '9' ? c-'0' :
@@ -1581,13 +1582,25 @@ function tryparse_internal{T<:Integer}(::Type{T}, s::AbstractString, base::Int,
15811582
end
15821583
(T <: Signed) && (d *= sgn)
15831584

1584-
safe_n = safe_mul(n, base)
1585-
safe_n.isnull || (safe_n = safe_add(safe_n.value, d))
1586-
if safe_n.isnull
1587-
raise && throw(OverflowError())
1588-
return _n
1585+
if (T===UInt128 || T===Int128) && (Base.WORD_SIZE < 64)
1586+
if raise
1587+
n = checked_add(checked_mul(n,base),d)
1588+
else
1589+
try
1590+
n = checked_add(checked_mul(n,base),d)
1591+
catch
1592+
return _n
1593+
end
1594+
end
1595+
else
1596+
safe_n = safe_mul(n, base)
1597+
safe_n.isnull || (safe_n = safe_add(safe_n.value, d))
1598+
if safe_n.isnull
1599+
raise && throw(OverflowError())
1600+
return _n
1601+
end
1602+
n = safe_n.value
15891603
end
1590-
n = safe_n.value
15911604
done(s,i) && return Nullable{T}(n)
15921605
c, i = next(s,i)
15931606
end

0 commit comments

Comments
 (0)
Please sign in to comment.