sharandac / My-TTGO-Watch

A GUI named hedge for smartwatch like devices based on ESP32. Currently support for T-Watch2020 (V1,V2,V3), T-Watch2021, M5Paper, M5Core2 and native Linux support for testing.
GNU General Public License v2.0
534 stars 246 forks source link

calculator: confusing output in 0/0 case #310

Closed pavelmachek closed 2 years ago

pavelmachek commented 2 years ago

Thanks for calculator improvements; with display on top saying what operations are going on, it is really easier to use.

But there's still confusing stuff.

"0 / 0 = - 5" results in display saying "0 - 5 = 0".

pavelmachek commented 2 years ago

Actually, it is not limited to 0/0 stuff. "long-C - 5 = " results in display saying "0 - 5 = 0", too. "long-C 0 - 5 =" behaves as expected.

sharandac commented 2 years ago

@d03n3rfr1tz3

d03n3rfr1tz3 commented 2 years ago

I guess it's because internally C/CE sets the value to NaN, but displays it as zero in the history. I'll have to look, if NaN is even needed anymore, as it's not possible to calculate anything with it. Otherwise I'll have to make sure that choosing the operator at least replaces the NaN with zero for further processing. Initially NaN was used to differentiate between an empty state (also empty display) and the active input of a zero. But as we switched to zero for the default display, it may be obsolete and in this case even breaking certain calculations.

Long story short, I'll have a look into it soon.