Calculator Utility
Version 53.16 (12.9.2012)
Try to do this math: 111111111 * 111111111
The solution should be 12345678987654321
It will produce an Overflow Error! instead
Is this considered normal or a bug?
Calculator: Overflow Error!
- tonyw
- AmigaOS Core Developer
- Posts: 1483
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: Calculator: Overflow Error!
I don't know what floating point format the Calculator uses, but your product is about 54 bits long, and if the mantissa is limited to 48 bits, it's going to overflow.
If you perform the multiplication in hex. it works OK.
If you perform the multiplication in hex. it works OK.
cheers
tony
tony
Re: Calculator: Overflow Error!
Hmm, ok, thanks for the infotonyw wrote:I don't know what floating point format the Calculator uses, but your product is about 54 bits long, and if the mantissa is limited to 48 bits, it's going to overflow.
If you perform the multiplication in hex. it works OK.
If it is limited, might there be a way to hand over such products to hex on-the-fly...instead of throwing an Error?
Or maybe up the mantissa(?) size?
- tonyw
- AmigaOS Core Developer
- Posts: 1483
- Joined: Wed Mar 09, 2011 1:36 pm
- Location: Sydney, Australia
Re: Calculator: Overflow Error!
I suppose you *could* (if you were the calculator) recognise that both the multipier and multiplicand are integers, and perform the operation in integer arithmetic, but that would mean that if you then take 37% of the result, it would have to convert to a float again, with another overflow error.
Looking at the code, I see that it uses IEEE 754, which has 54 bits of mantissa or up to 15 decimal digits. That is a "Double" float in C.
Looking at the code, I see that it uses IEEE 754, which has 54 bits of mantissa or up to 15 decimal digits. That is a "Double" float in C.
cheers
tony
tony