Skip to content

Commit b2f8ee8

Browse files
authored
make Base.uabs public 2 (JuliaLang#53503)
`Base.uabs` is helpful when writing code that works with generic integers without worrying about silent overflows or overflow errors when using integers from [SaferIntegers.jl](https://github.com/JeffreySarnoff/SaferIntegers.jl) `Base.uabs` is already being used by a few packages https://juliahub.com/ui/Search?q=uabs&type=code&w=true and has a docstring. However, it is currently an internal function. Ref: JeffreySarnoff/SaferIntegers.jl#41 Copy of JuliaLang#53376
1 parent cdd4ac5 commit b2f8ee8

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

base/float.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function ieee754_representation(
224224
end
225225

226226
"""
227-
uabs(x::Integer)
227+
Base.uabs(x::Integer)
228228
229229
Return the absolute value of `x`, possibly returning a different type should the
230230
operation be susceptible to overflow. This typically arises when `x` is a two's complement

base/public.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public
8080
isoperator,
8181
isunaryoperator,
8282

83+
# scalar math
84+
uabs,
85+
8386
# C interface
8487
cconvert,
8588
unsafe_convert,

doc/src/base/math.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ Base.invmod
187187
Base.powermod
188188
Base.ndigits
189189
Base.add_sum
190+
Base.uabs
190191
Base.widemul
191192
Base.Math.evalpoly
192193
Base.Math.@evalpoly

0 commit comments

Comments
 (0)