JuliaMath / JuliaMath/FixedPointDecimals.jl

Inconsistent error thrown for overflowing division depending on type

Open
#112 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
37
Forks
23
PR merge metrics
No merged PRs in 30d

Description

```
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.