## #100 Expression with MOD doesn't work

v1.0_(example)
closed-postponed
nobody
None
5
2014-01-30
2013-10-27
No

When I try to calculate the expression: (126^317) MOD 437 the result is: 412. This value is wrong.
The real value for this expression must be: 65.

Regards,

## Discussion

• Simon - 2013-10-27

Hi,

this calculation overflows with common floating point arithmetics, see for example

http://en.wikipedia.org/wiki/Arithmetic_overflow

There are special algorithms to solve "(126^317) MOD 437" (there has to be, as RSA en/decryption relies on this). However, such special algorithms are out of scope for galculator.

What is in scope for galculator is a warning, when a computation overflows. This is on galculator's todo list and will be part of the next release.

best, simon

• Cristiano Nunes - 2013-10-27

Hi Simon,

I've reported this as Bug, because the calculator of Windows 8 did this operation correctly. (Maybe it implements these algorithms)

I think this operation in the calculator should result in zero value or show a error message (I don't know).

Regards,

• Cristiano Nunes - 2013-10-27

I'm trying to resolve my homework about RSA encryption algorithms with galculator, but now I see that its not possible.

I'll be happy if galculator do this operations in the future.

Regards,

• Simon - 2014-01-30
• status: open --> closed-postponed

• Simon - 2014-01-30

I've to correct myself on this. The problem is not "overflowing", as we are computing with floating point numbers. The problem is "loss of precision", as we have too few significant digits to represent the result of the power operation precisely. We would need to use a library for arbitrary precision arithmetic such as gmp. This is on the wishlist, but will bot make its way into galculator soon.

best, simon