Skip to content

Commit

Permalink
prepare release 2.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Obermuhlner committed Nov 13, 2022
1 parent a74d36c commit a52c3eb
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ch.obermuhlner.math.big/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = 'ch.obermuhlner'
version = '2.3.1'
version = '2.3.2'
archivesBaseName = 'big-math'

ext {
Expand Down
8 changes: 8 additions & 0 deletions docs/releases/v2.3.1.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release 2.3.1

# IMPORTANT

The `big-math` release 2.3.1 published on maven central (https://search.maven.org/) was accidentally built with uncommitted experimental changes.

DO NOT USE RELEASE 2.3.1 AND USE 2.3.2 instead.

---

# API changes

## `BigRational` implements now `Serializable`
Expand Down
89 changes: 89 additions & 0 deletions docs/releases/v2.3.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Release 2.3.2

# API changes

## `BigRational` implements now `Serializable`

The `BigRational` class implements now the `Serializable` interface and can be serialized
with the standard Java approach using `ObjectInputStream` and deserialized using `ObjectOutputStream`.

## `BigRational` extends now `Number`

The `BigRational` class extends now from `Number` and provides the following standard methods:
- `int intValue()`
- `long longValue()`
- `float floatValue()`
- `double doubleValue()`


# Bugfixes

## `BigRational.toFloat()` and `BigRational.toDouble()` with large nominators/denominators

The methods `BigRational.toFloat()` and `BigRational.toDouble()` failed to convert large nominators/denominators
into valid `float`, respectively `double` numbers.

For example:
```java
BigRational x = BigRational.valueOf("8.804462619980757911125181749462772084351");
System.out.println("rational : " + x.toRationalString());
System.out.println("float : " + x.toFloat());
```

would print:
```
rational : 8804462619980757911125181749462772084351/1000000000000000000000000000000000000000
float : NaN
```

After the fix this example prints:
```
rational : 8804462619980757911125181749462772084351/1000000000000000000000000000000000000000
float : 8.804462
```


## `BigRational.toIntegerRationalString()` with small negative numbers

Negative rational numbers smaller than 1 where printed without `-` sign.

For example:
```java
BigRational v = valueOf(-1, 2);
System.out.println("small negative rational toString(): " + v);
System.out.println("small negative rational toIntegerRationalString(): " + v);
```

would print:
```
small negative rational toString(): -0.5
small negative rational toIntegerRationalString(): 1/2
```

After the fix this example prints:
```
small negative rational toString(): -0.5
small negative rational toIntegerRationalString(): -1/2
```


## `BigDecimalMath.root(x, n)` faster with large n

The `BigDecimalMath.root(BigDecimal, BigDecimal, MathContext)` function converged very slowly for larger values of n.

This was due to a bad initial value for the Newton-Raphson approximation.

Now the initial value for the Newton-Raphson approximation is calculated using double precision.
If the initial value cannot be calculated using double precision the function pow(x, 1/n) is used to calculate the root.


# Enhancements

No enhancements.


# Examples

Note: The example code is available on github, but not part of the big-math library.

No changes in the examples.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.obermuhlner</groupId>
<artifactId>big-math</artifactId>
<version>2.3.1</version>
<version>2.3.2</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down

0 comments on commit a52c3eb

Please sign in to comment.