Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] More advanced support for integer arithmetics #5

Open
3 tasks
tommens opened this issue Dec 28, 2023 · 0 comments
Open
3 tasks

[FEATURE] More advanced support for integer arithmetics #5

tommens opened this issue Dec 28, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@tommens
Copy link
Collaborator

tommens commented Dec 28, 2023

Describe the new functionality you would like to see

  • 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.

Additional context
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

@tommens tommens added the enhancement New feature or request label Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant