PaddiM8 / kalker

Scientific calculator with math syntax that supports user-defined variables and functions, complex numbers, and estimation of derivatives and integrals
https://kalker.xyz
MIT License
1.59k stars 70 forks source link

Wrong comparing with expressions #65

Closed Dartt0n closed 2 years ago

Dartt0n commented 2 years ago

I found this while using the program. The program incorrectly compares an expression with a trigonometric function and a number.

>> 3 * 4 * cos(60deg)
6
>> 3 * 4 * cos(60deg) <= 6
false
>> 3 * 4 * cos(60deg) > 6
true
>> 6 <= 6
true
>> 6 > 6
false

The 2nd and 3rd expressions are incorrect.

PaddiM8 commented 2 years ago

Ah yes. The problem seems to have been that comparisons are done too aggressively. Sometimes obviously you can't get exact numerical answers, which meant these tiny tiny differences (that normally get rounded appropriately before actually being displayed) would not be evaluated as being equal. This should now be fixed.