diff --git a/base/intfuncs.jl b/base/intfuncs.jl index 21677baa923e0..51a728b0b4b7d 100644 --- a/base/intfuncs.jl +++ b/base/intfuncs.jl @@ -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) @@ -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 @@ -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) @@ -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)