This repository is used for teaching purposes at the University of Mons. It contains Java code for computing arithmetic expressions. The code uses design patterns and is accompanied with JavaDoc, unit tests and BDD scenarios. We have also paid particular attention to code quality.
Describe the new functionality you would like to see
The current version of this code only provides support for integer arithmetic.
[x] We also would like to also have support for arithmetics on decimal/real numbers. One possibility would be to use float or double as internal type for such numbers, but I strongly suggest to use something like java.math.BigDecimal, which allows for arbitrary-precision decimal numbers and also provides operations for arithmetic, scale manipulation, rounding, comparison, hashing, and format conversion. Implementing this functionality should also include the following ones:
[x] Very large or very small decimal numbers should be expressible more compactly using the scientific notation or E-notation. for example, 6.022E23 would be considered as is equivalent to 6.022×10^23, which would be written as 6022 followed by 20 zeroes in "traditional" notation of natural numbers. Similarly, 1.6E-35 would be considered equivalent to 1.6×10^(−35) which would be written as 0.00...00016 (with lots of zeroes after the floating point of the decimal number).
[x] It should be possible to specify the precision of these decimal numbers (i.e., how many significant digits of a real number will be encoded). This precision can be fixed when constructing a calculator, but the application should be able to be configured with a given precision for decimal numbers. (It is left open for discussion whether it should be possible from within a running calculator itself to change the precision.)
[x] When supporting arithmetics on real numbers, care should be taken when carrying out operations that may result in an error. E.g. 0.0 / 0.0 is a NaN, i.e. an undefined number; 1.0/0.0 is either +infinity or a division by zero error, depending on whether infinity is allowed/supported by the calculator; -1.0/0.0 would be -infinity or a division by zero error; taking the square root of a negative number is not allowed (NaN); taking the logarithm of a negative value is not allowed (NaN) and so on. A clean, generic and reusable solution needs to be found for all such cases; knowing that the same types of problems may also occur for other number domains (integer values; fractions; complex number; ...)
[x] As supported on most scientific calculators, it should be possible to use and convert numbers from degrees or radians (the use of radians if often more intuitive and useful when working frequently with trigonometric functions like sin, cos, and so on).
Describe the new functionality you would like to see The current version of this code only provides support for integer arithmetic.