Skip to content

Commit 20c66f2

Browse files
committed
Clarify the _unsigned(x) methods with comments
1 parent 3f39b8a commit 20c66f2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/fldmod-by-const.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ given integer type, you can define this overload for your integer type.
3535
You will also need to implement some parts of the interface below, including _widen().
3636
"""
3737
ShouldUseCustomFldmodByConst(::Type{<:Base.BitInteger}) = true
38-
ShouldUseCustomFldmodByConst(::Type{<:Union{Int256,Int128}}) = true
38+
ShouldUseCustomFldmodByConst(::Type{<:Union{Int256,UInt256}}) = true
3939
ShouldUseCustomFldmodByConst(::Type) = false
4040

4141
@inline function fldmod_by_const(x, y)
@@ -130,10 +130,12 @@ end
130130

131131
# Annoyingly, Unsigned(T) isn't defined for BitIntegers types:
132132
# https://github.com/rfourquet/BitIntegers.jl/pull/2
133+
# Note: We do not need this for Int512, since we only widen to 512 _after_ calling
134+
# _unsigned, above. This code is only for supporting the built-in integer types, which only
135+
# go up to 128-bits (widened twice to 512). If a user wants to extend FixedDecimals for
136+
# other integer types, they will need to add methods to either _unsigned or unsigned.
133137
_unsigned(x) = unsigned(x)
134138
_unsigned(::Type{Int256}) = UInt256
135139
_unsigned(::Type{UInt256}) = UInt256
136-
_unsigned(::Type{Int128}) = UInt128
137-
_unsigned(::Type{UInt128}) = UInt128
138140

139141
nbits(x) = sizeof(x) * 8

0 commit comments

Comments
 (0)