Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ ndigits0znb(x::Bool, b::Integer) = x % Int

# The suffix "pb" stands for "positive base"
function ndigits0zpb(x::Integer, b::Integer)
@constprop :aggressive
# precondition: b > 1
x == 0 && return 0
b = Int(b)
Expand Down Expand Up @@ -822,6 +823,7 @@ julia> Base.ndigits0z(10)
See also [`ndigits`](@ref).
"""
function ndigits0z(x::Integer, b::Integer)
@constprop :aggressive
if b < -1
ndigits0znb(x, b)
elseif b > 1
Expand Down Expand Up @@ -1064,8 +1066,8 @@ function _base(base::Integer, x::Integer, pad::Int, neg::Bool)
return str
end

split_sign(n::Integer) = unsigned(abs(n)), n < 0
split_sign(n::Unsigned) = n, false
split_sign(n::Integer) = (unsigned(abs(n)), n < 0)
split_sign(n::Unsigned) = (n, false)

"""
string(n::Integer; base::Integer = 10, pad::Integer = 1)
Expand Down Expand Up @@ -1094,6 +1096,7 @@ julia> @sprintf("%4i", 5)
```
"""
function string(n::Integer; base::Integer = 10, pad::Integer = 1)
@constprop :aggressive
pad = (min(max(pad, typemin(Int)), typemax(Int)) % Int)::Int
if base == 2
(n_positive, neg) = split_sign(n)
Expand Down