FixedPointDecimals.jl icon indicating copy to clipboard operation
FixedPointDecimals.jl copied to clipboard

Inconsistent error thrown for overflowing division depending on type

Open mbarbar opened this issue 1 year ago • 0 comments

julia> typemin(FixedDecimal{Int32,4}) / -1
ERROR: OverflowError: -214748.3648 / -1 overflowed for type FixedDecimal{Int32, 4}
Stacktrace:
 [1] throw_overflowerr_binaryop(op::Symbol, x::FixedDecimal{Int32, 4}, y::Int64)
   @ Base.Checked ./checked.jl:163
 [2] checked_rdiv(x::FixedDecimal{Int32, 4}, y::Int64)
   @ FixedPointDecimals ~/.julia/packages/FixedPointDecimals/R0sp2/src/FixedPointDecimals.jl:570
 [3] /(x::FixedDecimal{Int32, 4}, y::Int64)
   @ FixedPointDecimals ~/.julia/packages/FixedPointDecimals/R0sp2/src/FixedPointDecimals.jl:229
 [4] top-level scope
   @ REPL[118]:1

julia> typemin(FixedDecimal{Int64,5}) / -1
ERROR: DivideError: integer division error
Stacktrace:
 [1] div
   @ ./int.jl:295 [inlined]
 [2] div
   @ ./div.jl:308 [inlined]
 [3] div
   @ ./div.jl:353 [inlined]
 [4] fld
   @ ./div.jl:319 [inlined]
 [5] divrem
   @ ./div.jl:205 [inlined]
 [6] fldmod
   @ ./div.jl:274 [inlined]
 [7] checked_rdiv(x::FixedDecimal{Int64, 5}, y::Int64)
   @ FixedPointDecimals ~/.julia/packages/FixedPointDecimals/R0sp2/src/FixedPointDecimals.jl:568
 [8] /(x::FixedDecimal{Int64, 5}, y::Int64)
   @ FixedPointDecimals ~/.julia/packages/FixedPointDecimals/R0sp2/src/FixedPointDecimals.jl:229
 [9] top-level scope
   @ REPL[120]:1

Whichever is chosen, they should be the same.

mbarbar avatar Feb 11 '25 14:02 mbarbar