Erroneous comparsion (>, <) results with oo and -oo and integers.
MCurve7 opened this issue · comments
When comparing the infinties oo and -oo with integers I get erroneous boolean results:
using SymPy
a=3
for i in -a:a
println("-oo < $i: $(-oo < i)")
end
for i in -a:a
println("oo < $i: $(oo < i)")
end
Results:
-oo < -3: true
-oo < -2: true
-oo < -1: false
-oo < 0: false
-oo < 1: false
-oo < 2: true
-oo < 3: true
and
oo < -3: true
oo < -2: true
oo < -1: true
oo < 0: false
oo < 1: false
oo < 2: true
oo < 3: true
I tested it out to -20:20 and the results were all true except as shown.
Same results with <= and >=.
Julia version 1.10.0
SymPy version 1.12
Thanks!
This is indeed unexpected and wrong. I put in a fix in #48, but hopefully it isn't deeper than that. (The compare method seems to give incorrect responses)
Thank you for the quick response and for providing this package!
I am not sure if I should open another Issue or if this is similair enough to the one I already opened. If I should open a new Issue let me know and I be happy to do so.
I have noticed a comparison issue with floats and positive infinity, oo.
using SymPy
a = 0.3
for i in -a:.1:a
println("$i < oo: $(i < oo)")
end
for i in -a:.1:a
println("-oo < $i: $(-oo < i)")
end
results in:
-0.3 < oo: false
-0.2 < oo: false
-0.1 < oo: false
0.0 < oo: false
0.1 < oo: false
0.2 < oo: false
0.3 < oo: false
I tested for a = 3.0 and got all false.
I also test -oo < i and it correctly resulted in true:
-oo < -0.3: true
-oo < -0.2: true
-oo < -0.1: true
-oo < 0.0: true
-oo < 0.1: true
-oo < 0.2: true
-oo < 0.3: true
Thanks! I'll have a look.
Thanks. I failed to change an x to a y the first go round. Really appreciate you taking the time to report this.
No problem and again thank you for you work.