serso / android-calculatorpp

Android Calculator
421 stars 201 forks source link

Trig functions ( sin(π), cos(π/2) ) evaluate incorrectly #209

Open sohxet opened 3 years ago

sohxet commented 3 years ago

Actual behaviour: When calculating these values the app incorrectly returns sin(π) = 122.465E-18 sin(-π) = -122.465E-18 cos(π/2) = 61.232E-18 cos(-π/2) = 61.232E-18

As a result Euler's formula also evaluates incorrectly { Euler's formula: e^(i*θ) = cos(θ) + i*sin(θ) } e^(i*π) = -1 + i*122.465E-18 e^(i*π/2) = 61.232E-18 + i

Expected behaviour: sin(π) = sin(-π) = 0 cos(π/2) = cos(-π/2) = 0 e^(i*π) = -1 e^(i*π/2) = i

Screenshot_20210823-155353_Calculator++ Screenshot_20210823-155331_Calculator++ Screenshot_20210823-155316_Calculator++ Screenshot_20210823-155300_Calculator++

Cloud-Galaxyman commented 2 years ago

I'm also having this issue. I'm glad this is on GitHub, and I love the UI and features of the calculator, but getting sin(π) as 122.4646799147E-18, just kind of freaks me out.
Like how can I trust this calculator on my HW if it can't do trig that I can do in my head?

hackerb9 commented 1 year ago

This is not a fix, but you can workaround the problem by going to settings and changing the Number Format from Engineering to Decimal. It will no longer show exponential notation which means infinitesimal numbers like 10^-16 will be shown as 0.

Screenshot_20230125-104448