Skip to content

Inconsistent error thrown for overflowing division depending on type #112

Description

@mbarbar
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions