• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

My Desire calculator calculates incorrect

Harry2

Extreme Android User
Jun 3, 2010
5,175
1,341
Black Forest
Hi,

I search a better calculator for my Desire.

The stock calculator calculates incorrect,
e.g. 100-99.9=0.0999999999

The new calculator should very easy to use (and calculate correctly).
Mathematical functions to show graphically would be nice :)

With these many, many calculators in the market it is hard to find the right.

Harry
 
The stock calculator calculates incorrect, e.g. 100-99.9=0.0999999999
What's happening there?
This is most likely because the calculator isn't using enough internal precision (that is, the right type of variable for floating-point math; possibly a float where a double should have been used).

The thing is, computers love numbers but inherently suck at decimals. :eek:
You know how you can express "1/2" quite perfectly as "0.5", but for "1/3" you get the problem that "0.33333..." is never going to be entirely accurate? The same thing happens in binary, only on different occasions.

So when you hit one of those occasions, you will see a precision error in the form of a number that is "ever so slightly" smaller or larger than you'd expect.

Wikipedia: Representing_fractions_in_binary gives the following example.
Examples:
integer bits fractional bits
Code:
0.5    =
 
  • Like
Reactions: Harry2
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones