Calculator: Overflow Error!

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
Raziel

Calculator: Overflow Error!

Post by Raziel »

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?
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1483
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: Calculator: Overflow Error!

Post by tonyw »

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.
cheers
tony
Raziel

Re: Calculator: Overflow Error!

Post by Raziel »

tonyw 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.
Hmm, ok, thanks for the info

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?
User avatar
tonyw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 1483
Joined: Wed Mar 09, 2011 1:36 pm
Location: Sydney, Australia

Re: Calculator: Overflow Error!

Post by tonyw »

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.
cheers
tony
Post Reply