Int8(8) // Int8(100)im == -50im
due to overflow
#53435
Labels
bug
Indicates an unexpected problem or unintended behavior
complex
Complex numbers
correctness bug ⚠
Bugs that are likely to lead to incorrect results in user code without throwing
rationals
The Rational type and values thereof
The current method for
//
onInteger
andComplex{<:Integer}
can overflow, silently giving an incorrect answer. For example:The expected answer is
0//1 - 2//25*im
The issue is caused by
abs2
andconj
onComplex{Int8}
silently overflowing in:julia/base/rational.jl
Line 101 in ccba6c9
One solution could be to specialize this method on the many different combinations of
Complex{<:Rational}
,Complex{<:Integer}
,Rational
,Integer
, andNumber
for the inputs, and check for overflow when doing anyInteger
math. Maybe there is a nicer way to fix this issue.The text was updated successfully, but these errors were encountered: