You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

403 lines
16 KiB

3 years ago
  1. # Changelog
  2. All notable changes to this project will be documented in this file.
  3. ## [0.9.1](https://github.com/brick/math/releases/tag/0.9.1) - 2020-08-19
  4. ✨ New features
  5. - `BigInteger::not()` returns the bitwise `NOT` value
  6. 🐛 **Bug fixes**
  7. - `BigInteger::toBytes()` could return an incorrect binary representation for some numbers
  8. - The bitwise operations `and()`, `or()`, `xor()` on `BigInteger` could return an incorrect result when the GMP extension is not available
  9. ## [0.9.0](https://github.com/brick/math/releases/tag/0.9.0) - 2020-08-18
  10. 👌 **Improvements**
  11. - `BigNumber::of()` now accepts `.123` and `123.` formats, both of which return a `BigDecimal`
  12. 💥 **Breaking changes**
  13. - Deprecated method `BigInteger::powerMod()` has been removed - use `modPow()` instead
  14. - Deprecated method `BigInteger::parse()` has been removed - use `fromBase()` instead
  15. ## [0.8.9](https://github.com/brick/math/releases/tag/0.8.9) - 2020-01-08
  16. ⚡️ **Performance improvements**
  17. A few additional optimizations in `BigInteger` and `BigDecimal` when one of the operands can be returned as is. Thanks to @tomtomsen in #24.
  18. ## [0.8.8](https://github.com/brick/math/releases/tag/0.8.8) - 2019-04-25
  19. 🐛 **Bug fixes**
  20. - `BigInteger::toBase()` could return an empty string for zero values (BCMath & Native calculators only, GMP calculator unaffected)
  21. **New features**
  22. - `BigInteger::toArbitraryBase()` converts a number to an arbitrary base, using a custom alphabet
  23. - `BigInteger::fromArbitraryBase()` converts a string in an arbitrary base, using a custom alphabet, back to a number
  24. These methods can be used as the foundation to convert strings between different bases/alphabets, using BigInteger as an intermediate representation.
  25. 💩 **Deprecations**
  26. - `BigInteger::parse()` is now deprecated in favour of `fromBase()`
  27. `BigInteger::fromBase()` works the same way as `parse()`, with 2 minor differences:
  28. - the `$base` parameter is required, it does not default to `10`
  29. - it throws a `NumberFormatException` instead of an `InvalidArgumentException` when the number is malformed
  30. ## [0.8.7](https://github.com/brick/math/releases/tag/0.8.7) - 2019-04-20
  31. **Improvements**
  32. - Safer conversion from `float` when using custom locales
  33. - **Much faster** `NativeCalculator` implementation 🚀
  34. 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.
  35. ## [0.8.6](https://github.com/brick/math/releases/tag/0.8.6) - 2019-04-11
  36. **New method**
  37. `BigNumber::sum()` returns the sum of one or more numbers.
  38. ## [0.8.5](https://github.com/brick/math/releases/tag/0.8.5) - 2019-02-12
  39. **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).
  40. Thanks @manowark 👍
  41. ## [0.8.4](https://github.com/brick/math/releases/tag/0.8.4) - 2018-12-07
  42. **New method**
  43. `BigDecimal::sqrt()` calculates the square root of a decimal number, to a given scale.
  44. ## [0.8.3](https://github.com/brick/math/releases/tag/0.8.3) - 2018-12-06
  45. **New method**
  46. `BigInteger::sqrt()` calculates the square root of a number (thanks @peter279k).
  47. **New exception**
  48. `NegativeNumberException` is thrown when calling `sqrt()` on a negative number.
  49. ## [0.8.2](https://github.com/brick/math/releases/tag/0.8.2) - 2018-11-08
  50. **Performance update**
  51. - Further improvement of `toInt()` performance
  52. - `NativeCalculator` can now perform some multiplications more efficiently
  53. ## [0.8.17](https://github.com/brick/math/releases/tag/0.8.17) - 2020-08-19
  54. 🐛 **Bug fix**
  55. - `BigInteger::toBytes()` could return an incorrect binary representation for some numbers
  56. - The bitwise operations `and()`, `or()`, `xor()` on `BigInteger` could return an incorrect result when the GMP extension is not available
  57. ## [0.8.16](https://github.com/brick/math/releases/tag/0.8.16) - 2020-08-18
  58. 🚑 **Critical fix**
  59. - 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.
  60. **New features**
  61. - `BigInteger::modInverse()` calculates a modular multiplicative inverse
  62. - `BigInteger::fromBytes()` creates a `BigInteger` from a byte string
  63. - `BigInteger::toBytes()` converts a `BigInteger` to a byte string
  64. - `BigInteger::randomBits()` creates a pseudo-random `BigInteger` of a given bit length
  65. - `BigInteger::randomRange()` creates a pseudo-random `BigInteger` between two bounds
  66. 💩 **Deprecations**
  67. - `BigInteger::powerMod()` is now deprecated in favour of `modPow()`
  68. ## [0.8.15](https://github.com/brick/math/releases/tag/0.8.15) - 2020-04-15
  69. 🐛 **Fixes**
  70. - added missing `ext-json` requirement, due to `BigNumber` implementing `JsonSerializable`
  71. ⚡️ **Optimizations**
  72. - additional optimization in `BigInteger::remainder()`
  73. ## [0.8.14](https://github.com/brick/math/releases/tag/0.8.14) - 2020-02-18
  74. **New features**
  75. - `BigInteger::getLowestSetBit()` returns the index of the rightmost one bit
  76. ## [0.8.13](https://github.com/brick/math/releases/tag/0.8.13) - 2020-02-16
  77. **New features**
  78. - `BigInteger::isEven()` tests whether the number is even
  79. - `BigInteger::isOdd()` tests whether the number is odd
  80. - `BigInteger::testBit()` tests if a bit is set
  81. - `BigInteger::getBitLength()` returns the number of bits in the minimal representation of the number
  82. ## [0.8.12](https://github.com/brick/math/releases/tag/0.8.12) - 2020-02-03
  83. 🛠️ **Maintenance release**
  84. Classes are now annotated for better static analysis with [psalm](https://psalm.dev/).
  85. This is a maintenance release: no bug fixes, no new features, no breaking changes.
  86. ## [0.8.11](https://github.com/brick/math/releases/tag/0.8.11) - 2020-01-23
  87. **New feature**
  88. `BigInteger::powerMod()` performs a power-with-modulo operation. Useful for crypto.
  89. ## [0.8.10](https://github.com/brick/math/releases/tag/0.8.10) - 2020-01-21
  90. **New feature**
  91. `BigInteger::mod()` returns the **modulo** of two numbers. The *modulo* differs from the *remainder* when the signs of the operands are different.
  92. ## [0.8.1](https://github.com/brick/math/releases/tag/0.8.1) - 2018-11-07
  93. Performance optimization of `toInt()` methods.
  94. ## [0.8.0](https://github.com/brick/math/releases/tag/0.8.0) - 2018-10-13
  95. **Breaking changes**
  96. The following deprecated methods have been removed. Use the new method name instead:
  97. | Method removed | Replacement method |
  98. | --- | --- |
  99. | `BigDecimal::getIntegral()` | `BigDecimal::getIntegralPart()` |
  100. | `BigDecimal::getFraction()` | `BigDecimal::getFractionalPart()` |
  101. ---
  102. **New features**
  103. `BigInteger` has been augmented with 5 new methods for bitwise operations:
  104. | New method | Description |
  105. | --- | --- |
  106. | `and()` | performs a bitwise `AND` operation on two numbers |
  107. | `or()` | performs a bitwise `OR` operation on two numbers |
  108. | `xor()` | performs a bitwise `XOR` operation on two numbers |
  109. | `shiftedLeft()` | returns the number shifted left by a number of bits |
  110. | `shiftedRight()` | returns the number shifted right by a number of bits |
  111. Thanks to @DASPRiD 👍
  112. ## [0.7.3](https://github.com/brick/math/releases/tag/0.7.3) - 2018-08-20
  113. **New method:** `BigDecimal::hasNonZeroFractionalPart()`
  114. **Renamed/deprecated methods:**
  115. - `BigDecimal::getIntegral()` has been renamed to `getIntegralPart()` and is now deprecated
  116. - `BigDecimal::getFraction()` has been renamed to `getFractionalPart()` and is now deprecated
  117. ## [0.7.2](https://github.com/brick/math/releases/tag/0.7.2) - 2018-07-21
  118. **Performance update**
  119. `BigInteger::parse()` and `toBase()` now use GMP's built-in base conversion features when available.
  120. ## [0.7.1](https://github.com/brick/math/releases/tag/0.7.1) - 2018-03-01
  121. This is a maintenance release, no code has been changed.
  122. - When installed with `--no-dev`, the autoloader does not autoload tests anymore
  123. - Tests and other files unnecessary for production are excluded from the dist package
  124. This will help make installations more compact.
  125. ## [0.7.0](https://github.com/brick/math/releases/tag/0.7.0) - 2017-10-02
  126. Methods renamed:
  127. - `BigNumber:sign()` has been renamed to `getSign()`
  128. - `BigDecimal::unscaledValue()` has been renamed to `getUnscaledValue()`
  129. - `BigDecimal::scale()` has been renamed to `getScale()`
  130. - `BigDecimal::integral()` has been renamed to `getIntegral()`
  131. - `BigDecimal::fraction()` has been renamed to `getFraction()`
  132. - `BigRational::numerator()` has been renamed to `getNumerator()`
  133. - `BigRational::denominator()` has been renamed to `getDenominator()`
  134. Classes renamed:
  135. - `ArithmeticException` has been renamed to `MathException`
  136. ## [0.6.2](https://github.com/brick/math/releases/tag/0.6.2) - 2017-10-02
  137. The base class for all exceptions is now `MathException`.
  138. `ArithmeticException` has been deprecated, and will be removed in 0.7.0.
  139. ## [0.6.1](https://github.com/brick/math/releases/tag/0.6.1) - 2017-10-02
  140. A number of methods have been renamed:
  141. - `BigNumber:sign()` is deprecated; use `getSign()` instead
  142. - `BigDecimal::unscaledValue()` is deprecated; use `getUnscaledValue()` instead
  143. - `BigDecimal::scale()` is deprecated; use `getScale()` instead
  144. - `BigDecimal::integral()` is deprecated; use `getIntegral()` instead
  145. - `BigDecimal::fraction()` is deprecated; use `getFraction()` instead
  146. - `BigRational::numerator()` is deprecated; use `getNumerator()` instead
  147. - `BigRational::denominator()` is deprecated; use `getDenominator()` instead
  148. The old methods will be removed in version 0.7.0.
  149. ## [0.6.0](https://github.com/brick/math/releases/tag/0.6.0) - 2017-08-25
  150. - Minimum PHP version is now [7.1](https://gophp71.org/); for PHP 5.6 and PHP 7.0 support, use version `0.5`
  151. - Deprecated method `BigDecimal::withScale()` has been removed; use `toScale()` instead
  152. - Method `BigNumber::toInteger()` has been renamed to `toInt()`
  153. ## [0.5.4](https://github.com/brick/math/releases/tag/0.5.4) - 2016-10-17
  154. `BigNumber` classes now implement [JsonSerializable](http://php.net/manual/en/class.jsonserializable.php).
  155. The JSON output is always a string.
  156. ## [0.5.3](https://github.com/brick/math/releases/tag/0.5.3) - 2016-03-31
  157. 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.
  158. ## [0.5.2](https://github.com/brick/math/releases/tag/0.5.2) - 2015-08-06
  159. The `$scale` parameter of `BigDecimal::dividedBy()` is now optional again.
  160. ## [0.5.1](https://github.com/brick/math/releases/tag/0.5.1) - 2015-07-05
  161. **New method: `BigNumber::toScale()`**
  162. This allows to convert any `BigNumber` to a `BigDecimal` with a given scale, using rounding if necessary.
  163. ## [0.5.0](https://github.com/brick/math/releases/tag/0.5.0) - 2015-07-04
  164. **New features**
  165. - Common `BigNumber` interface for all classes, with the following methods:
  166. - `sign()` and derived methods (`isZero()`, `isPositive()`, ...)
  167. - `compareTo()` and derived methods (`isEqualTo()`, `isGreaterThan()`, ...) that work across different `BigNumber` types
  168. - `toBigInteger()`, `toBigDecimal()`, `toBigRational`() conversion methods
  169. - `toInteger()` and `toFloat()` conversion methods to native types
  170. - Unified `of()` behaviour: every class now accepts any type of number, provided that it can be safely converted to the current type
  171. - New method: `BigDecimal::exactlyDividedBy()`; this method automatically computes the scale of the result, provided that the division yields a finite number of digits
  172. - New methods: `BigRational::quotient()` and `remainder()`
  173. - Fine-grained exceptions: `DivisionByZeroException`, `RoundingNecessaryException`, `NumberFormatException`
  174. - Factory methods `zero()`, `one()` and `ten()` available in all classes
  175. - Rounding mode reintroduced in `BigInteger::dividedBy()`
  176. This release also comes with many performance improvements.
  177. ---
  178. **Breaking changes**
  179. - `BigInteger`:
  180. - `getSign()` is renamed to `sign()`
  181. - `toString()` is renamed to `toBase()`
  182. - `BigInteger::dividedBy()` now throws an exception by default if the remainder is not zero; use `quotient()` to get the previous behaviour
  183. - `BigDecimal`:
  184. - `getSign()` is renamed to `sign()`
  185. - `getUnscaledValue()` is renamed to `unscaledValue()`
  186. - `getScale()` is renamed to `scale()`
  187. - `getIntegral()` is renamed to `integral()`
  188. - `getFraction()` is renamed to `fraction()`
  189. - `divideAndRemainder()` is renamed to `quotientAndRemainder()`
  190. - `dividedBy()` now takes a **mandatory** `$scale` parameter **before** the rounding mode
  191. - `toBigInteger()` does not accept a `$roundingMode` parameter any more
  192. - `toBigRational()` does not simplify the fraction any more; explicitly add `->simplified()` to get the previous behaviour
  193. - `BigRational`:
  194. - `getSign()` is renamed to `sign()`
  195. - `getNumerator()` is renamed to `numerator()`
  196. - `getDenominator()` is renamed to `denominator()`
  197. - `of()` is renamed to `nd()`, while `parse()` is renamed to `of()`
  198. - Miscellaneous:
  199. - `ArithmeticException` is moved to an `Exception\` sub-namespace
  200. - `of()` factory methods now throw `NumberFormatException` instead of `InvalidArgumentException`
  201. ## [0.4.3](https://github.com/brick/math/releases/tag/0.4.3) - 2016-03-31
  202. Backport of two bug fixes from the 0.5 branch:
  203. - `BigInteger::parse()` did not always throw `InvalidArgumentException` as expected
  204. - 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.
  205. ## [0.4.2](https://github.com/brick/math/releases/tag/0.4.2) - 2015-06-16
  206. New method: `BigDecimal::stripTrailingZeros()`
  207. ## [0.4.1](https://github.com/brick/math/releases/tag/0.4.1) - 2015-06-12
  208. Introducing a `BigRational` class, to perform calculations on fractions of any size.
  209. ## [0.4.0](https://github.com/brick/math/releases/tag/0.4.0) - 2015-06-12
  210. Rounding modes have been removed from `BigInteger`, and are now a concept specific to `BigDecimal`.
  211. `BigInteger::dividedBy()` now always returns the quotient of the division.
  212. ## [0.3.5](https://github.com/brick/math/releases/tag/0.3.5) - 2016-03-31
  213. Backport of two bug fixes from the 0.5 branch:
  214. - `BigInteger::parse()` did not always throw `InvalidArgumentException` as expected
  215. - 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.
  216. ## [0.3.4](https://github.com/brick/math/releases/tag/0.3.4) - 2015-06-11
  217. New methods:
  218. - `BigInteger::remainder()` returns the remainder of a division only
  219. - `BigInteger::gcd()` returns the greatest common divisor of two numbers
  220. ## [0.3.3](https://github.com/brick/math/releases/tag/0.3.3) - 2015-06-07
  221. Fix `toString()` not handling negative numbers.
  222. ## [0.3.2](https://github.com/brick/math/releases/tag/0.3.2) - 2015-06-07
  223. `BigInteger` and `BigDecimal` now have a `getSign()` method that returns:
  224. - `-1` if the number is negative
  225. - `0` if the number is zero
  226. - `1` if the number is positive
  227. ## [0.3.1](https://github.com/brick/math/releases/tag/0.3.1) - 2015-06-05
  228. Minor performance improvements
  229. ## [0.3.0](https://github.com/brick/math/releases/tag/0.3.0) - 2015-06-04
  230. The `$roundingMode` and `$scale` parameters have been swapped in `BigDecimal::dividedBy()`.
  231. ## [0.2.2](https://github.com/brick/math/releases/tag/0.2.2) - 2015-06-04
  232. Stronger immutability guarantee for `BigInteger` and `BigDecimal`.
  233. So far, it would have been possible to break immutability of these classes by calling the `unserialize()` internal function. This release fixes that.
  234. ## [0.2.1](https://github.com/brick/math/releases/tag/0.2.1) - 2015-06-02
  235. Added `BigDecimal::divideAndRemainder()`
  236. ## [0.2.0](https://github.com/brick/math/releases/tag/0.2.0) - 2015-05-22
  237. - `min()` and `max()` do not accept an `array` any more, but a variable number of parameters
  238. - **minimum PHP version is now 5.6**
  239. - continuous integration with PHP 7
  240. ## [0.1.1](https://github.com/brick/math/releases/tag/0.1.1) - 2014-09-01
  241. - Added `BigInteger::power()`
  242. - Added HHVM support
  243. ## [0.1.0](https://github.com/brick/math/releases/tag/0.1.0) - 2014-08-31
  244. First beta release.