| Summary: | Calculator doesn't correctly calculate division by zero | ||
|---|---|---|---|
| Product: | [Unmaintained] kdeplasma-addons | Reporter: | Martin Flöser <mgraesslin> |
| Component: | calculator | Assignee: | Plasma Bugs List <plasma-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | minor | CC: | bshah, ivan.cukic, justin.zobel, kde, kde, nate, plasma-bugs-null |
| Priority: | NOR | ||
| Version First Reported In: | 5.3.90 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | https://invent.kde.org/plasma/kdeplasma-addons/commit/a4f73ea230ccdffa359dfea69951e95d292b9dfb | Version Fixed/Implemented In: | 6.0 |
| Sentry Crash Report: | |||
|
Description
Martin Flöser
2015-06-06 23:15:02 UTC
KRunner also shows "Infinity" for 1/0 and "NaN" for 0/0 (In reply to Kai Uwe Broulik from comment #1) > KRunner also shows "Infinity" for 1/0 and "NaN" for 0/0 not here: it shows "1/0" and "0/0" >The result of division by zero is undefined
Then it doesn't matter what the result is. That's the definition of undefined.
Infinity or NaN aren't exactly wrong. Personally I'd close this as wontfix.
Will let calculator maintainer decide.
NaN could be interpreted as undefined, infinity not. Infinity is not an undefined value, but a pretty clear value. Also NaN as an output is wrong - which non technical user would know that it stands for "Not a Number"? I agree with Martin. Division by zero is always undefined, it is not infinity nor NaN. It has been defined for IEEE754 to have special values of Infinity and 'I'm Not a Number, I'm a free man' :) because of non-precise floating-point arithmetic. The most I'd go for is an answer along the lines of 'Not defined (Infinity according to IEEE754 standard)' but IMO this would be an overkill. > > The result of division by zero is undefined > Then it doesn't matter what the result is. > That's the definition of undefined. The definition of undefined is that a function is not defined for the provided arguments. Not that it does not matter what the result is. > Infinity or NaN aren't exactly wrong. The *are* exactly wrong. In the same way as using 42 as an answer would be wrong. p.s. Similar thing also happens for sqrt(-4) - it returns NaN, but it should be 'undefined'. Both show nan as the result. Still an issue on kdeplasma-addons from git master. A possibly relevant merge request was started @ https://invent.kde.org/plasma/kdeplasma-addons/-/merge_requests/319 Git commit a4f73ea230ccdffa359dfea69951e95d292b9dfb by Nate Graham, on behalf of Martin Frueh. Committed on 23/02/2023 at 14:48. Pushed by ngraham into branch 'master'. catch division by zero and show correct result (undfined) M +10 -0 applets/calculator/package/contents/ui/calculator.qml https://invent.kde.org/plasma/kdeplasma-addons/commit/a4f73ea230ccdffa359dfea69951e95d292b9dfb |