|
| 1 | +# Release 2.3.1 |
| 2 | + |
| 3 | +# API changes |
| 4 | + |
| 5 | +## `BigRational` implements now `Serializable` |
| 6 | + |
| 7 | +The `BigRational` class implements now the `Serializable` interface and can be serialized |
| 8 | +with the standard Java approach using `ObjectInputStream` and deserialized using `ObjectOutputStream`. |
| 9 | + |
| 10 | +## `BigRational` extends now `Number` |
| 11 | + |
| 12 | +The `BigRational` class extends now from `Number` and provides the following standard methods: |
| 13 | +- `int intValue()` |
| 14 | +- `long longValue()` |
| 15 | +- `float floatValue()` |
| 16 | +- `double doubleValue()` |
| 17 | + |
| 18 | + |
| 19 | +# Bugfixes |
| 20 | + |
| 21 | +## `BigRational.toFloat()` and `BigRational.toDouble()` with large nominators/denominators |
| 22 | + |
| 23 | +The methods `BigRational.toFloat()` and `BigRational.toDouble()` failed to convert large nominators/denominators |
| 24 | +into valid `float`, respectively `double` numbers. |
| 25 | + |
| 26 | +For example: |
| 27 | +```java |
| 28 | +BigRational x = BigRational.valueOf("8.804462619980757911125181749462772084351"); |
| 29 | +System.out.println("rational : " + x.toRationalString()); |
| 30 | +System.out.println("float : " + x.toFloat()); |
| 31 | +``` |
| 32 | + |
| 33 | +would print: |
| 34 | +``` |
| 35 | +rational : 8804462619980757911125181749462772084351/1000000000000000000000000000000000000000 |
| 36 | +float : NaN |
| 37 | +``` |
| 38 | + |
| 39 | +After the fix this example prints: |
| 40 | +``` |
| 41 | +rational : 8804462619980757911125181749462772084351/1000000000000000000000000000000000000000 |
| 42 | +float : 8.804462 |
| 43 | +``` |
| 44 | + |
| 45 | + |
| 46 | +## `BigRational.toIntegerRationalString()` with small negative numbers |
| 47 | + |
| 48 | +Negative rational numbers smaller than 1 where printed without `-` sign. |
| 49 | + |
| 50 | +For example: |
| 51 | +```java |
| 52 | +BigRational v = valueOf(-1, 2); |
| 53 | +System.out.println("small negative rational toString(): " + v); |
| 54 | +System.out.println("small negative rational toIntegerRationalString(): " + v); |
| 55 | +``` |
| 56 | + |
| 57 | +would print: |
| 58 | +``` |
| 59 | +small negative rational toString(): -0.5 |
| 60 | +small negative rational toIntegerRationalString(): 1/2 |
| 61 | +``` |
| 62 | + |
| 63 | +After the fix this example prints: |
| 64 | +``` |
| 65 | +small negative rational toString(): -0.5 |
| 66 | +small negative rational toIntegerRationalString(): -1/2 |
| 67 | +``` |
| 68 | + |
| 69 | + |
| 70 | +## `BigDecimalMath.root(x, n)` faster with large n |
| 71 | + |
| 72 | +The `BigDecimalMath.root(BigDecimal, BigDecimal, MathContext)` function converged very slowly for larger values of n. |
| 73 | + |
| 74 | +This was due to a bad initial value for the Newton-Raphson approximation. |
| 75 | + |
| 76 | +Now the initial value for the Newton-Raphson approximation is calculated using double precision. |
| 77 | +If the initial value cannot be calculated using double precision the function pow(x, 1/n) is used to calculate the root. |
| 78 | + |
| 79 | + |
| 80 | +# Enhancements |
| 81 | + |
| 82 | +No enhancements. |
| 83 | + |
| 84 | + |
| 85 | +# Examples |
| 86 | + |
| 87 | +Note: The example code is available on github, but not part of the big-math library. |
| 88 | + |
| 89 | +No changes in the examples. |
0 commit comments