| 1 |
# Changelog |
| 2 |
|
| 3 |
All notable changes to this project will be documented in this file. |
| 4 |
|
| 5 |
## [](https://github.com/brick/math/releases/tag/0.13.10.13.1](https://github.com/brick/math/releases/tag/0.13.1](https://github.com/brick/math/releases/tag/0.13.1) - 2025-03-29 |
| 6 |
|
| 7 |
✨ **Improvements** |
| 8 |
|
| 9 |
- `__toString()` methods of `BigInteger` and `BigDecimal` are now type-hinted as returning `numeric-string` instead of `string` (#90 by @vudaltsov) |
| 10 |
|
| 11 |
## [](https://github.com/brick/math/releases/tag/0.13.00.13.0](https://github.com/brick/math/releases/tag/0.13.0](https://github.com/brick/math/releases/tag/0.13.0) - 2025-03-03 |
| 12 |
|
| 13 |
💥 **Breaking changes** |
| 14 |
|
| 15 |
- `BigDecimal::ofUnscaledValue()` no longer throws an exception if the scale is negative |
| 16 |
- `MathException` now extends `RuntimeException` instead of `Exception`; this reverts the change introduced in version `0.11.0` (#82) |
| 17 |
|
| 18 |
✨ **New features** |
| 19 |
|
| 20 |
- `BigDecimal::ofUnscaledValue()` allows a negative scale (and converts the values to create a zero scale number) |
| 21 |
|
| 22 |
## [](https://github.com/brick/math/releases/tag/0.12.30.12.3](https://github.com/brick/math/releases/tag/0.12.3](https://github.com/brick/math/releases/tag/0.12.3) - 2025-02-28 |
| 23 |
|
| 24 |
✨ **New features** |
| 25 |
|
| 26 |
- `BigDecimal::getPrecision()` Returns the number of significant digits in a decimal number |
| 27 |
|
| 28 |
## [](https://github.com/brick/math/releases/tag/0.12.20.12.2](https://github.com/brick/math/releases/tag/0.12.2](https://github.com/brick/math/releases/tag/0.12.2) - 2025-02-26 |
| 29 |
|
| 30 |
⚡️ **Performance improvements** |
| 31 |
|
| 32 |
- Division in `NativeCalculator` is now faster for small divisors, thanks to [](https://github.com/Izumi-kun@Izumi-kun](https://github.com/Izumi-kun](https://github.com/Izumi-kun) in [](https://github.com/brick/math/pull/87#87](https://github.com/brick/math/pull/87](https://github.com/brick/math/pull/87). |
| 33 |
|
| 34 |
👌 **Improvements** |
| 35 |
|
| 36 |
- Add missing `RoundingNecessaryException` to the `@throws` annotation of `BigNumber::of()` |
| 37 |
|
| 38 |
## [](https://github.com/brick/math/releases/tag/0.12.10.12.1](https://github.com/brick/math/releases/tag/0.12.1](https://github.com/brick/math/releases/tag/0.12.1) - 2023-11-29 |
| 39 |
|
| 40 |
⚡️ **Performance improvements** |
| 41 |
|
| 42 |
- `BigNumber::of()` is now faster, thanks to [](https://github.com/SebastienDug@SebastienDug](https://github.com/SebastienDug](https://github.com/SebastienDug) in [](https://github.com/brick/math/pull/77#77](https://github.com/brick/math/pull/77](https://github.com/brick/math/pull/77). |
| 43 |
|
| 44 |
## [](https://github.com/brick/math/releases/tag/0.12.00.12.0](https://github.com/brick/math/releases/tag/0.12.0](https://github.com/brick/math/releases/tag/0.12.0) - 2023-11-26 |
| 45 |
|
| 46 |
💥 **Breaking changes** |
| 47 |
|
| 48 |
- Minimum PHP version is now 8.1 |
| 49 |
- `RoundingMode` is now an `enum`; if you're type-hinting rounding modes, you need to type-hint against `RoundingMode` instead of `int` now |
| 50 |
- `BigNumber` classes do not implement the `Serializable` interface anymore (they use the [](https://wiki.php.net/rfc/custom_object_serializationnew custom object serialization mechanism](https://wiki.php.net/rfc/custom_object_serialization](https://wiki.php.net/rfc/custom_object_serialization)) |
| 51 |
- The following breaking changes only affect you if you're creating your own `BigNumber` subclasses: |
| 52 |
- the return type of `BigNumber::of()` is now `static` |
| 53 |
- `BigNumber` has a new abstract method `from()` |
| 54 |
- all `public` and `protected` functions of `BigNumber` are now `final` |
| 55 |
|
| 56 |
## [](https://github.com/brick/math/releases/tag/0.11.00.11.0](https://github.com/brick/math/releases/tag/0.11.0](https://github.com/brick/math/releases/tag/0.11.0) - 2023-01-16 |
| 57 |
|
| 58 |
💥 **Breaking changes** |
| 59 |
|
| 60 |
- Minimum PHP version is now 8.0 |
| 61 |
- Methods accepting a union of types are now strongly typed<sup>*</sup> |
| 62 |
- `MathException` now extends `Exception` instead of `RuntimeException` |
| 63 |
|
| 64 |
<sup>* You may now run into type errors if you were passing `Stringable` objects to `of()` or any of the methods |
| 65 |
internally calling `of()`, with `strict_types` enabled. You can fix this by casting `Stringable` objects to `string` |
| 66 |
first.</sup> |
| 67 |
|
| 68 |
## [](https://github.com/brick/math/releases/tag/0.10.20.10.2](https://github.com/brick/math/releases/tag/0.10.2](https://github.com/brick/math/releases/tag/0.10.2) - 2022-08-11 |
| 69 |
|
| 70 |
👌 **Improvements** |
| 71 |
|
| 72 |
- `BigRational::toFloat()` now simplifies the fraction before performing division (#73) thanks to @olsavmic |
| 73 |
|
| 74 |
## [](https://github.com/brick/math/releases/tag/0.10.10.10.1](https://github.com/brick/math/releases/tag/0.10.1](https://github.com/brick/math/releases/tag/0.10.1) - 2022-08-02 |
| 75 |
|
| 76 |
✨ **New features** |
| 77 |
|
| 78 |
- `BigInteger::gcdMultiple()` returns the GCD of multiple `BigInteger` numbers |
| 79 |
|
| 80 |
## [](https://github.com/brick/math/releases/tag/0.10.00.10.0](https://github.com/brick/math/releases/tag/0.10.0](https://github.com/brick/math/releases/tag/0.10.0) - 2022-06-18 |
| 81 |
|
| 82 |
💥 **Breaking changes** |
| 83 |
|
| 84 |
- Minimum PHP version is now 7.4 |
| 85 |
|
| 86 |
## [](https://github.com/brick/math/releases/tag/0.9.30.9.3](https://github.com/brick/math/releases/tag/0.9.3](https://github.com/brick/math/releases/tag/0.9.3) - 2021-08-15 |
| 87 |
|
| 88 |
🚀 **Compatibility with PHP 8.1** |
| 89 |
|
| 90 |
- Support for custom object serialization; this removes a warning on PHP 8.1 due to the `Serializable` interface being deprecated (#60) thanks @TRowbotham |
| 91 |
|
| 92 |
## [](https://github.com/brick/math/releases/tag/0.9.20.9.2](https://github.com/brick/math/releases/tag/0.9.2](https://github.com/brick/math/releases/tag/0.9.2) - 2021-01-20 |
| 93 |
|
| 94 |
🐛 **Bug fix** |
| 95 |
|
| 96 |
- Incorrect results could be returned when using the BCMath calculator, with a default scale set with `bcscale()`, on PHP >= 7.2 (#55). |
| 97 |
|
| 98 |
## [](https://github.com/brick/math/releases/tag/0.9.10.9.1](https://github.com/brick/math/releases/tag/0.9.1](https://github.com/brick/math/releases/tag/0.9.1) - 2020-08-19 |
| 99 |
|
| 100 |
✨ **New features** |
| 101 |
|
| 102 |
- `BigInteger::not()` returns the bitwise `NOT` value |
| 103 |
|
| 104 |
🐛 **Bug fixes** |
| 105 |
|
| 106 |
- `BigInteger::toBytes()` could return an incorrect binary representation for some numbers |
| 107 |
- The bitwise operations `and()`, `or()`, `xor()` on `BigInteger` could return an incorrect result when the GMP extension is not available |
| 108 |
|
| 109 |
## [](https://github.com/brick/math/releases/tag/0.9.00.9.0](https://github.com/brick/math/releases/tag/0.9.0](https://github.com/brick/math/releases/tag/0.9.0) - 2020-08-18 |
| 110 |
|
| 111 |
👌 **Improvements** |
| 112 |
|
| 113 |
- `BigNumber::of()` now accepts `.123` and `123.` formats, both of which return a `BigDecimal` |
| 114 |
|
| 115 |
💥 **Breaking changes** |
| 116 |
|
| 117 |
- Deprecated method `BigInteger::powerMod()` has been removed - use `modPow()` instead |
| 118 |
- Deprecated method `BigInteger::parse()` has been removed - use `fromBase()` instead |
| 119 |
|
| 120 |
## [](https://github.com/brick/math/releases/tag/0.8.170.8.17](https://github.com/brick/math/releases/tag/0.8.17](https://github.com/brick/math/releases/tag/0.8.17) - 2020-08-19 |
| 121 |
|
| 122 |
🐛 **Bug fix** |
| 123 |
|
| 124 |
- `BigInteger::toBytes()` could return an incorrect binary representation for some numbers |
| 125 |
- The bitwise operations `and()`, `or()`, `xor()` on `BigInteger` could return an incorrect result when the GMP extension is not available |
| 126 |
|
| 127 |
## [](https://github.com/brick/math/releases/tag/0.8.160.8.16](https://github.com/brick/math/releases/tag/0.8.16](https://github.com/brick/math/releases/tag/0.8.16) - 2020-08-18 |
| 128 |
|
| 129 |
🚑 **Critical fix** |
| 130 |
|
| 131 |
- This version reintroduces the deprecated `BigInteger::parse()` method, that has been removed by mistake in version `0.8.9` and should have lasted for the whole `0.8` release cycle. |
| 132 |
|
| 133 |
✨ **New features** |
| 134 |
|
| 135 |
- `BigInteger::modInverse()` calculates a modular multiplicative inverse |
| 136 |
- `BigInteger::fromBytes()` creates a `BigInteger` from a byte string |
| 137 |
- `BigInteger::toBytes()` converts a `BigInteger` to a byte string |
| 138 |
- `BigInteger::randomBits()` creates a pseudo-random `BigInteger` of a given bit length |
| 139 |
- `BigInteger::randomRange()` creates a pseudo-random `BigInteger` between two bounds |
| 140 |
|
| 141 |
💩 **Deprecations** |
| 142 |
|
| 143 |
- `BigInteger::powerMod()` is now deprecated in favour of `modPow()` |
| 144 |
|
| 145 |
## [](https://github.com/brick/math/releases/tag/0.8.150.8.15](https://github.com/brick/math/releases/tag/0.8.15](https://github.com/brick/math/releases/tag/0.8.15) - 2020-04-15 |
| 146 |
|
| 147 |
🐛 **Fixes** |
| 148 |
|
| 149 |
- added missing `ext-json` requirement, due to `BigNumber` implementing `JsonSerializable` |
| 150 |
|
| 151 |
⚡️ **Optimizations** |
| 152 |
|
| 153 |
- additional optimization in `BigInteger::remainder()` |
| 154 |
|
| 155 |
## [](https://github.com/brick/math/releases/tag/0.8.140.8.14](https://github.com/brick/math/releases/tag/0.8.14](https://github.com/brick/math/releases/tag/0.8.14) - 2020-02-18 |
| 156 |
|
| 157 |
✨ **New features** |
| 158 |
|
| 159 |
- `BigInteger::getLowestSetBit()` returns the index of the rightmost one bit |
| 160 |
|
| 161 |
## [](https://github.com/brick/math/releases/tag/0.8.130.8.13](https://github.com/brick/math/releases/tag/0.8.13](https://github.com/brick/math/releases/tag/0.8.13) - 2020-02-16 |
| 162 |
|
| 163 |
✨ **New features** |
| 164 |
|
| 165 |
- `BigInteger::isEven()` tests whether the number is even |
| 166 |
- `BigInteger::isOdd()` tests whether the number is odd |
| 167 |
- `BigInteger::testBit()` tests if a bit is set |
| 168 |
- `BigInteger::getBitLength()` returns the number of bits in the minimal representation of the number |
| 169 |
|
| 170 |
## [](https://github.com/brick/math/releases/tag/0.8.120.8.12](https://github.com/brick/math/releases/tag/0.8.12](https://github.com/brick/math/releases/tag/0.8.12) - 2020-02-03 |
| 171 |
|
| 172 |
🛠️ **Maintenance release** |
| 173 |
|
| 174 |
Classes are now annotated for better static analysis with [](https://psalm.dev/psalm](https://psalm.dev/](https://psalm.dev/). |
| 175 |
|
| 176 |
This is a maintenance release: no bug fixes, no new features, no breaking changes. |
| 177 |
|
| 178 |
## [](https://github.com/brick/math/releases/tag/0.8.110.8.11](https://github.com/brick/math/releases/tag/0.8.11](https://github.com/brick/math/releases/tag/0.8.11) - 2020-01-23 |
| 179 |
|
| 180 |
✨ **New feature** |
| 181 |
|
| 182 |
`BigInteger::powerMod()` performs a power-with-modulo operation. Useful for crypto. |
| 183 |
|
| 184 |
## [](https://github.com/brick/math/releases/tag/0.8.100.8.10](https://github.com/brick/math/releases/tag/0.8.10](https://github.com/brick/math/releases/tag/0.8.10) - 2020-01-21 |
| 185 |
|
| 186 |
✨ **New feature** |
| 187 |
|
| 188 |
`BigInteger::mod()` returns the **modulo** of two numbers. The *modulo* differs from the *remainder* when the signs of the operands are different. |
| 189 |
|
| 190 |
## [](https://github.com/brick/math/releases/tag/0.8.90.8.9](https://github.com/brick/math/releases/tag/0.8.9](https://github.com/brick/math/releases/tag/0.8.9) - 2020-01-08 |
| 191 |
|
| 192 |
⚡️ **Performance improvements** |
| 193 |
|
| 194 |
A few additional optimizations in `BigInteger` and `BigDecimal` when one of the operands can be returned as is. Thanks to @tomtomsen in #24. |
| 195 |
|
| 196 |
## [](https://github.com/brick/math/releases/tag/0.8.80.8.8](https://github.com/brick/math/releases/tag/0.8.8](https://github.com/brick/math/releases/tag/0.8.8) - 2019-04-25 |
| 197 |
|
| 198 |
🐛 **Bug fixes** |
| 199 |
|
| 200 |
- `BigInteger::toBase()` could return an empty string for zero values (BCMath & Native calculators only, GMP calculator unaffected) |
| 201 |
|
| 202 |
✨ **New features** |
| 203 |
|
| 204 |
- `BigInteger::toArbitraryBase()` converts a number to an arbitrary base, using a custom alphabet |
| 205 |
- `BigInteger::fromArbitraryBase()` converts a string in an arbitrary base, using a custom alphabet, back to a number |
| 206 |
|
| 207 |
These methods can be used as the foundation to convert strings between different bases/alphabets, using BigInteger as an intermediate representation. |
| 208 |
|
| 209 |
💩 **Deprecations** |
| 210 |
|
| 211 |
- `BigInteger::parse()` is now deprecated in favour of `fromBase()` |
| 212 |
|
| 213 |
`BigInteger::fromBase()` works the same way as `parse()`, with 2 minor differences: |
| 214 |
|
| 215 |
- the `$base` parameter is required, it does not default to `10` |
| 216 |
- it throws a `NumberFormatException` instead of an `InvalidArgumentException` when the number is malformed |
| 217 |
|
| 218 |
## [](https://github.com/brick/math/releases/tag/0.8.70.8.7](https://github.com/brick/math/releases/tag/0.8.7](https://github.com/brick/math/releases/tag/0.8.7) - 2019-04-20 |
| 219 |
|
| 220 |
**Improvements** |
| 221 |
|
| 222 |
- Safer conversion from `float` when using custom locales |
| 223 |
- **Much faster** `NativeCalculator` implementation 🚀 |
| 224 |
|
| 225 |
You can expect **at least a 3x performance improvement** for common arithmetic operations when using the library on systems without GMP or BCMath; it gets exponentially faster on multiplications with a high number of digits. This is due to calculations now being performed on whole blocks of digits (the block size depending on the platform, 32-bit or 64-bit) instead of digit-by-digit as before. |
| 226 |
|
| 227 |
## [](https://github.com/brick/math/releases/tag/0.8.60.8.6](https://github.com/brick/math/releases/tag/0.8.6](https://github.com/brick/math/releases/tag/0.8.6) - 2019-04-11 |
| 228 |
|
| 229 |
**New method** |
| 230 |
|
| 231 |
`BigNumber::sum()` returns the sum of one or more numbers. |
| 232 |
|
| 233 |
## [](https://github.com/brick/math/releases/tag/0.8.50.8.5](https://github.com/brick/math/releases/tag/0.8.5](https://github.com/brick/math/releases/tag/0.8.5) - 2019-02-12 |
| 234 |
|
| 235 |
**Bug fix**: `of()` factory methods could fail when passing a `float` in environments using a `LC_NUMERIC` locale with a decimal separator other than `'.'` (#20). |
| 236 |
|
| 237 |
Thanks @manowark 👍 |
| 238 |
|
| 239 |
## [](https://github.com/brick/math/releases/tag/0.8.40.8.4](https://github.com/brick/math/releases/tag/0.8.4](https://github.com/brick/math/releases/tag/0.8.4) - 2018-12-07 |
| 240 |
|
| 241 |
**New method** |
| 242 |
|
| 243 |
`BigDecimal::sqrt()` calculates the square root of a decimal number, to a given scale. |
| 244 |
|
| 245 |
## [](https://github.com/brick/math/releases/tag/0.8.30.8.3](https://github.com/brick/math/releases/tag/0.8.3](https://github.com/brick/math/releases/tag/0.8.3) - 2018-12-06 |
| 246 |
|
| 247 |
**New method** |
| 248 |
|
| 249 |
`BigInteger::sqrt()` calculates the square root of a number (thanks @peter279k). |
| 250 |
|
| 251 |
**New exception** |
| 252 |
|
| 253 |
`NegativeNumberException` is thrown when calling `sqrt()` on a negative number. |
| 254 |
|
| 255 |
## [](https://github.com/brick/math/releases/tag/0.8.20.8.2](https://github.com/brick/math/releases/tag/0.8.2](https://github.com/brick/math/releases/tag/0.8.2) - 2018-11-08 |
| 256 |
|
| 257 |
**Performance update** |
| 258 |
|
| 259 |
- Further improvement of `toInt()` performance |
| 260 |
- `NativeCalculator` can now perform some multiplications more efficiently |
| 261 |
|
| 262 |
## [](https://github.com/brick/math/releases/tag/0.8.10.8.1](https://github.com/brick/math/releases/tag/0.8.1](https://github.com/brick/math/releases/tag/0.8.1) - 2018-11-07 |
| 263 |
|
| 264 |
Performance optimization of `toInt()` methods. |
| 265 |
|
| 266 |
## [](https://github.com/brick/math/releases/tag/0.8.00.8.0](https://github.com/brick/math/releases/tag/0.8.0](https://github.com/brick/math/releases/tag/0.8.0) - 2018-10-13 |
| 267 |
|
| 268 |
**Breaking changes** |
| 269 |
|
| 270 |
The following deprecated methods have been removed. Use the new method name instead: |
| 271 |
|
| 272 |
| Method removed | Replacement method | |
| 273 |
| --- | --- | |
| 274 |
| `BigDecimal::getIntegral()` | `BigDecimal::getIntegralPart()` | |
| 275 |
| `BigDecimal::getFraction()` | `BigDecimal::getFractionalPart()` | |
| 276 |
|
| 277 |
--- |
| 278 |
|
| 279 |
**New features** |
| 280 |
|
| 281 |
`BigInteger` has been augmented with 5 new methods for bitwise operations: |
| 282 |
|
| 283 |
| New method | Description | |
| 284 |
| --- | --- | |
| 285 |
| `and()` | performs a bitwise `AND` operation on two numbers | |
| 286 |
| `or()` | performs a bitwise `OR` operation on two numbers | |
| 287 |
| `xor()` | performs a bitwise `XOR` operation on two numbers | |
| 288 |
| `shiftedLeft()` | returns the number shifted left by a number of bits | |
| 289 |
| `shiftedRight()` | returns the number shifted right by a number of bits | |
| 290 |
|
| 291 |
Thanks to @DASPRiD 👍 |
| 292 |
|
| 293 |
## [](https://github.com/brick/math/releases/tag/0.7.30.7.3](https://github.com/brick/math/releases/tag/0.7.3](https://github.com/brick/math/releases/tag/0.7.3) - 2018-08-20 |
| 294 |
|
| 295 |
**New method:** `BigDecimal::hasNonZeroFractionalPart()` |
| 296 |
|
| 297 |
**Renamed/deprecated methods:** |
| 298 |
|
| 299 |
- `BigDecimal::getIntegral()` has been renamed to `getIntegralPart()` and is now deprecated |
| 300 |
- `BigDecimal::getFraction()` has been renamed to `getFractionalPart()` and is now deprecated |
| 301 |
|
| 302 |
## [](https://github.com/brick/math/releases/tag/0.7.20.7.2](https://github.com/brick/math/releases/tag/0.7.2](https://github.com/brick/math/releases/tag/0.7.2) - 2018-07-21 |
| 303 |
|
| 304 |
**Performance update** |
| 305 |
|
| 306 |
`BigInteger::parse()` and `toBase()` now use GMP's built-in base conversion features when available. |
| 307 |
|
| 308 |
## [](https://github.com/brick/math/releases/tag/0.7.10.7.1](https://github.com/brick/math/releases/tag/0.7.1](https://github.com/brick/math/releases/tag/0.7.1) - 2018-03-01 |
| 309 |
|
| 310 |
This is a maintenance release, no code has been changed. |
| 311 |
|
| 312 |
- When installed with `--no-dev`, the autoloader does not autoload tests anymore |
| 313 |
- Tests and other files unnecessary for production are excluded from the dist package |
| 314 |
|
| 315 |
This will help make installations more compact. |
| 316 |
|
| 317 |
## [](https://github.com/brick/math/releases/tag/0.7.00.7.0](https://github.com/brick/math/releases/tag/0.7.0](https://github.com/brick/math/releases/tag/0.7.0) - 2017-10-02 |
| 318 |
|
| 319 |
Methods renamed: |
| 320 |
|
| 321 |
- `BigNumber:sign()` has been renamed to `getSign()` |
| 322 |
- `BigDecimal::unscaledValue()` has been renamed to `getUnscaledValue()` |
| 323 |
- `BigDecimal::scale()` has been renamed to `getScale()` |
| 324 |
- `BigDecimal::integral()` has been renamed to `getIntegral()` |
| 325 |
- `BigDecimal::fraction()` has been renamed to `getFraction()` |
| 326 |
- `BigRational::numerator()` has been renamed to `getNumerator()` |
| 327 |
- `BigRational::denominator()` has been renamed to `getDenominator()` |
| 328 |
|
| 329 |
Classes renamed: |
| 330 |
|
| 331 |
- `ArithmeticException` has been renamed to `MathException` |
| 332 |
|
| 333 |
## [](https://github.com/brick/math/releases/tag/0.6.20.6.2](https://github.com/brick/math/releases/tag/0.6.2](https://github.com/brick/math/releases/tag/0.6.2) - 2017-10-02 |
| 334 |
|
| 335 |
The base class for all exceptions is now `MathException`. |
| 336 |
`ArithmeticException` has been deprecated, and will be removed in 0.7.0. |
| 337 |
|
| 338 |
## [](https://github.com/brick/math/releases/tag/0.6.10.6.1](https://github.com/brick/math/releases/tag/0.6.1](https://github.com/brick/math/releases/tag/0.6.1) - 2017-10-02 |
| 339 |
|
| 340 |
A number of methods have been renamed: |
| 341 |
|
| 342 |
- `BigNumber:sign()` is deprecated; use `getSign()` instead |
| 343 |
- `BigDecimal::unscaledValue()` is deprecated; use `getUnscaledValue()` instead |
| 344 |
- `BigDecimal::scale()` is deprecated; use `getScale()` instead |
| 345 |
- `BigDecimal::integral()` is deprecated; use `getIntegral()` instead |
| 346 |
- `BigDecimal::fraction()` is deprecated; use `getFraction()` instead |
| 347 |
- `BigRational::numerator()` is deprecated; use `getNumerator()` instead |
| 348 |
- `BigRational::denominator()` is deprecated; use `getDenominator()` instead |
| 349 |
|
| 350 |
The old methods will be removed in version 0.7.0. |
| 351 |
|
| 352 |
## [](https://github.com/brick/math/releases/tag/0.6.00.6.0](https://github.com/brick/math/releases/tag/0.6.0](https://github.com/brick/math/releases/tag/0.6.0) - 2017-08-25 |
| 353 |
|
| 354 |
- Minimum PHP version is now [](https://gophp71.org/7.1](https://gophp71.org/](https://gophp71.org/); for PHP 5.6 and PHP 7.0 support, use version `0.5` |
| 355 |
- Deprecated method `BigDecimal::withScale()` has been removed; use `toScale()` instead |
| 356 |
- Method `BigNumber::toInteger()` has been renamed to `toInt()` |
| 357 |
|
| 358 |
## [](https://github.com/brick/math/releases/tag/0.5.40.5.4](https://github.com/brick/math/releases/tag/0.5.4](https://github.com/brick/math/releases/tag/0.5.4) - 2016-10-17 |
| 359 |
|
| 360 |
`BigNumber` classes now implement [](http://php.net/manual/en/class.jsonserializable.phpJsonSerializable](http://php.net/manual/en/class.jsonserializable.php](http://php.net/manual/en/class.jsonserializable.php). |
| 361 |
The JSON output is always a string. |
| 362 |
|
| 363 |
## [](https://github.com/brick/math/releases/tag/0.5.30.5.3](https://github.com/brick/math/releases/tag/0.5.3](https://github.com/brick/math/releases/tag/0.5.3) - 2016-03-31 |
| 364 |
|
| 365 |
This is a bugfix release. Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6. |
| 366 |
|
| 367 |
## [](https://github.com/brick/math/releases/tag/0.5.20.5.2](https://github.com/brick/math/releases/tag/0.5.2](https://github.com/brick/math/releases/tag/0.5.2) - 2015-08-06 |
| 368 |
|
| 369 |
The `$scale` parameter of `BigDecimal::dividedBy()` is now optional again. |
| 370 |
|
| 371 |
## [](https://github.com/brick/math/releases/tag/0.5.10.5.1](https://github.com/brick/math/releases/tag/0.5.1](https://github.com/brick/math/releases/tag/0.5.1) - 2015-07-05 |
| 372 |
|
| 373 |
**New method: `BigNumber::toScale()`** |
| 374 |
|
| 375 |
This allows to convert any `BigNumber` to a `BigDecimal` with a given scale, using rounding if necessary. |
| 376 |
|
| 377 |
## [](https://github.com/brick/math/releases/tag/0.5.00.5.0](https://github.com/brick/math/releases/tag/0.5.0](https://github.com/brick/math/releases/tag/0.5.0) - 2015-07-04 |
| 378 |
|
| 379 |
**New features** |
| 380 |
- Common `BigNumber` interface for all classes, with the following methods: |
| 381 |
- `sign()` and derived methods (`isZero()`, `isPositive()`, ...) |
| 382 |
- `compareTo()` and derived methods (`isEqualTo()`, `isGreaterThan()`, ...) that work across different `BigNumber` types |
| 383 |
- `toBigInteger()`, `toBigDecimal()`, `toBigRational`() conversion methods |
| 384 |
- `toInteger()` and `toFloat()` conversion methods to native types |
| 385 |
- Unified `of()` behaviour: every class now accepts any type of number, provided that it can be safely converted to the current type |
| 386 |
- New method: `BigDecimal::exactlyDividedBy()`; this method automatically computes the scale of the result, provided that the division yields a finite number of digits |
| 387 |
- New methods: `BigRational::quotient()` and `remainder()` |
| 388 |
- Fine-grained exceptions: `DivisionByZeroException`, `RoundingNecessaryException`, `NumberFormatException` |
| 389 |
- Factory methods `zero()`, `one()` and `ten()` available in all classes |
| 390 |
- Rounding mode reintroduced in `BigInteger::dividedBy()` |
| 391 |
|
| 392 |
This release also comes with many performance improvements. |
| 393 |
|
| 394 |
--- |
| 395 |
|
| 396 |
**Breaking changes** |
| 397 |
- `BigInteger`: |
| 398 |
- `getSign()` is renamed to `sign()` |
| 399 |
- `toString()` is renamed to `toBase()` |
| 400 |
- `BigInteger::dividedBy()` now throws an exception by default if the remainder is not zero; use `quotient()` to get the previous behaviour |
| 401 |
- `BigDecimal`: |
| 402 |
- `getSign()` is renamed to `sign()` |
| 403 |
- `getUnscaledValue()` is renamed to `unscaledValue()` |
| 404 |
- `getScale()` is renamed to `scale()` |
| 405 |
- `getIntegral()` is renamed to `integral()` |
| 406 |
- `getFraction()` is renamed to `fraction()` |
| 407 |
- `divideAndRemainder()` is renamed to `quotientAndRemainder()` |
| 408 |
- `dividedBy()` now takes a **mandatory** `$scale` parameter **before** the rounding mode |
| 409 |
- `toBigInteger()` does not accept a `$roundingMode` parameter anymore |
| 410 |
- `toBigRational()` does not simplify the fraction anymore; explicitly add `->simplified()` to get the previous behaviour |
| 411 |
- `BigRational`: |
| 412 |
- `getSign()` is renamed to `sign()` |
| 413 |
- `getNumerator()` is renamed to `numerator()` |
| 414 |
- `getDenominator()` is renamed to `denominator()` |
| 415 |
- `of()` is renamed to `nd()`, while `parse()` is renamed to `of()` |
| 416 |
- Miscellaneous: |
| 417 |
- `ArithmeticException` is moved to an `Exception\` sub-namespace |
| 418 |
- `of()` factory methods now throw `NumberFormatException` instead of `InvalidArgumentException` |
| 419 |
|
| 420 |
## [](https://github.com/brick/math/releases/tag/0.4.30.4.3](https://github.com/brick/math/releases/tag/0.4.3](https://github.com/brick/math/releases/tag/0.4.3) - 2016-03-31 |
| 421 |
|
| 422 |
Backport of two bug fixes from the 0.5 branch: |
| 423 |
- `BigInteger::parse()` did not always throw `InvalidArgumentException` as expected |
| 424 |
- Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6. |
| 425 |
|
| 426 |
## [](https://github.com/brick/math/releases/tag/0.4.20.4.2](https://github.com/brick/math/releases/tag/0.4.2](https://github.com/brick/math/releases/tag/0.4.2) - 2015-06-16 |
| 427 |
|
| 428 |
New method: `BigDecimal::stripTrailingZeros()` |
| 429 |
|
| 430 |
## [](https://github.com/brick/math/releases/tag/0.4.10.4.1](https://github.com/brick/math/releases/tag/0.4.1](https://github.com/brick/math/releases/tag/0.4.1) - 2015-06-12 |
| 431 |
|
| 432 |
Introducing a `BigRational` class, to perform calculations on fractions of any size. |
| 433 |
|
| 434 |
## [](https://github.com/brick/math/releases/tag/0.4.00.4.0](https://github.com/brick/math/releases/tag/0.4.0](https://github.com/brick/math/releases/tag/0.4.0) - 2015-06-12 |
| 435 |
|
| 436 |
Rounding modes have been removed from `BigInteger`, and are now a concept specific to `BigDecimal`. |
| 437 |
|
| 438 |
`BigInteger::dividedBy()` now always returns the quotient of the division. |
| 439 |
|
| 440 |
## [](https://github.com/brick/math/releases/tag/0.3.50.3.5](https://github.com/brick/math/releases/tag/0.3.5](https://github.com/brick/math/releases/tag/0.3.5) - 2016-03-31 |
| 441 |
|
| 442 |
Backport of two bug fixes from the 0.5 branch: |
| 443 |
|
| 444 |
- `BigInteger::parse()` did not always throw `InvalidArgumentException` as expected |
| 445 |
- Dividing by a negative power of 1 with the same scale as the dividend could trigger an incorrect optimization which resulted in a wrong result. See #6. |
| 446 |
|
| 447 |
## [](https://github.com/brick/math/releases/tag/0.3.40.3.4](https://github.com/brick/math/releases/tag/0.3.4](https://github.com/brick/math/releases/tag/0.3.4) - 2015-06-11 |
| 448 |
|
| 449 |
New methods: |
| 450 |
- `BigInteger::remainder()` returns the remainder of a division only |
| 451 |
- `BigInteger::gcd()` returns the greatest common divisor of two numbers |
| 452 |
|
| 453 |
## [](https://github.com/brick/math/releases/tag/0.3.30.3.3](https://github.com/brick/math/releases/tag/0.3.3](https://github.com/brick/math/releases/tag/0.3.3) - 2015-06-07 |
| 454 |
|
| 455 |
Fix `toString()` not handling negative numbers. |
| 456 |
|
| 457 |
## [](https://github.com/brick/math/releases/tag/0.3.20.3.2](https://github.com/brick/math/releases/tag/0.3.2](https://github.com/brick/math/releases/tag/0.3.2) - 2015-06-07 |
| 458 |
|
| 459 |
`BigInteger` and `BigDecimal` now have a `getSign()` method that returns: |
| 460 |
- `-1` if the number is negative |
| 461 |
- `0` if the number is zero |
| 462 |
- `1` if the number is positive |
| 463 |
|
| 464 |
## [](https://github.com/brick/math/releases/tag/0.3.10.3.1](https://github.com/brick/math/releases/tag/0.3.1](https://github.com/brick/math/releases/tag/0.3.1) - 2015-06-05 |
| 465 |
|
| 466 |
Minor performance improvements |
| 467 |
|
| 468 |
## [](https://github.com/brick/math/releases/tag/0.3.00.3.0](https://github.com/brick/math/releases/tag/0.3.0](https://github.com/brick/math/releases/tag/0.3.0) - 2015-06-04 |
| 469 |
|
| 470 |
The `$roundingMode` and `$scale` parameters have been swapped in `BigDecimal::dividedBy()`. |
| 471 |
|
| 472 |
## [](https://github.com/brick/math/releases/tag/0.2.20.2.2](https://github.com/brick/math/releases/tag/0.2.2](https://github.com/brick/math/releases/tag/0.2.2) - 2015-06-04 |
| 473 |
|
| 474 |
Stronger immutability guarantee for `BigInteger` and `BigDecimal`. |
| 475 |
|
| 476 |
So far, it would have been possible to break immutability of these classes by calling the `unserialize()` internal function. This release fixes that. |
| 477 |
|
| 478 |
## [](https://github.com/brick/math/releases/tag/0.2.10.2.1](https://github.com/brick/math/releases/tag/0.2.1](https://github.com/brick/math/releases/tag/0.2.1) - 2015-06-02 |
| 479 |
|
| 480 |
Added `BigDecimal::divideAndRemainder()` |
| 481 |
|
| 482 |
## [](https://github.com/brick/math/releases/tag/0.2.00.2.0](https://github.com/brick/math/releases/tag/0.2.0](https://github.com/brick/math/releases/tag/0.2.0) - 2015-05-22 |
| 483 |
|
| 484 |
- `min()` and `max()` do not accept an `array` anymore, but a variable number of parameters |
| 485 |
- **minimum PHP version is now 5.6** |
| 486 |
- continuous integration with PHP 7 |
| 487 |
|
| 488 |
## [](https://github.com/brick/math/releases/tag/0.1.10.1.1](https://github.com/brick/math/releases/tag/0.1.1](https://github.com/brick/math/releases/tag/0.1.1) - 2014-09-01 |
| 489 |
|
| 490 |
- Added `BigInteger::power()` |
| 491 |
- Added HHVM support |
| 492 |
|
| 493 |
## [](https://github.com/brick/math/releases/tag/0.1.00.1.0](https://github.com/brick/math/releases/tag/0.1.0](https://github.com/brick/math/releases/tag/0.1.0) - 2014-08-31 |
| 494 |
|
| 495 |
First beta release. |
| 496 |
|
| 497 |
|