You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Better exception handling: The current code is not checking for division by zero exceptions. The current code does not check for exceptions such as too large integers that are not supported by the internal data type (int) used in the MyNumber class. int values are 32 bit in Java, so the values range from -2^31 to 2^31-1. To deal with longer integer values, one could use to “long” type to supports 64 bit integers, i.e., values range from -2^63 to 2^63-1. But an even better alternative would be to use the java.Math.BigInteger class which supports arbitrary-precision integers, and which also provides a set of extra and useful operations that might be useful to support (for modular arithmetic, GCD calculation, primality testing, prime generation, bit manipulation).
It should be possible to represent and manipulate numbers in different bases n (eg. , 2=binary, 8= octal, 16=hexadecimal, and so on...), and to convert numbers between these different bases. Note that, in order to support hexadecimal numbers (especially in combination with a GUI, one also needs to be able to use the A to F characters in the number representation.
To be discussed whether and how we want to support other bases above 10, and how to represent these numbers. We could easily go up to 36 (since we have 26 letters in the alphabet on top of the 10 digits from 0 to 9. I would not go higher than base 36, since in practice nobody will be using that.
Add support for modular arithmetic. Modular arithmetic is for exemple used frequently in cryptography. It is like regular integer arithmetics, but restricted to a limited range of positive integer values. To implement this functionality, it is good to know that java.Math.BigInteger already provides some support for modular arithmetics. Modular numbers allow for new operations, such as the modular multiplicative inverse of a number. Equality checking on modular numbers is also different. For example, under "modulo 5", 4 and 9 should be considered as equal. For more information on modular arithmetic, see for exemple https://brilliant.org/wiki/modular-arithmetic/
and http://www.crypto-it.net/eng/theory/modular-arithmetic.html
The text was updated successfully, but these errors were encountered:
To be discussed whether and how we want to support other bases above 10, and how to represent these numbers. We could easily go up to 36 (since we have 26 letters in the alphabet on top of the 10 digits from 0 to 9. I would not go higher than base 36, since in practice nobody will be using that.
https://brilliant.org/wiki/modular-arithmetic/
and http://www.crypto-it.net/eng/theory/modular-arithmetic.html
The text was updated successfully, but these errors were encountered: