Benjamin Morel
321c00281d
CS fixes
...
Shorthand "int" and "bool" are now used instead of "integer" and "boolean".
This makes more sense as the latter are not accepted as synonyms in PHP 7 scalar type hints and return types.
2015-06-21 14:37:51 +02:00
Benjamin Morel
12bea2c474
BigInteger::toString() is now toBase()
2015-06-21 14:21:28 +02:00
Benjamin Morel
3195126bbe
Introduce a common interface for big numbers
...
Note that to accommodate the interface, BigDecimal::toBigInteger() does not accept a rounding mode any more.
2015-06-20 10:55:33 +02:00
Benjamin Morel
540ff57c0e
Add BigDecimal::dividedByExact()
2015-06-20 10:37:29 +02:00
Benjamin Morel
8f296871f2
Add BigRational::toBigDecimal()
2015-06-20 00:36:01 +02:00
Benjamin Morel
7ef1c1fa0d
isFiniteDecimal() tests for negative values
2015-06-19 14:19:48 +02:00
Benjamin Morel
c9a518affc
Add BigRational::isFiniteDecimal()
2015-06-19 14:10:31 +02:00
Benjamin Morel
9a043bebf4
Add BigDecimal::toBigRational()
2015-06-19 13:09:44 +02:00
Benjamin Morel
ac691e01e5
Add BigDecimal::stripTrailingZeros()
2015-06-17 00:40:31 +02:00
Benjamin Morel
095ae53a9b
BigRational now implements Serializable
...
This allows for a more compact serialized representation.
2015-06-12 23:35:34 +02:00
Benjamin Morel
b1239d9f44
Add tests for lines not covered
2015-06-12 23:07:22 +02:00
Benjamin Morel
38e7c83089
Add a BigRational class to deal with fractions
2015-06-12 15:49:35 +02:00
Benjamin Morel
cc30889769
BigInteger::dividedBy() now always returns the quotient
...
Rounding is a concept left to BigDecimal only from now on.
2015-06-12 10:25:00 +00:00
Benjamin Morel
115455238b
Clean up unused imports
2015-06-12 01:20:44 +02:00
Benjamin Morel
0dcae82742
Remove useless of() call in tests
2015-06-12 01:17:42 +02:00
Benjamin Morel
4f4b9531ed
Add BigInteger::gcd()
...
This computes the greatest common divisor of two large integers.
2015-06-11 23:35:47 +02:00
Benjamin Morel
1f577afe11
Add BigInteger::remainder() method
...
This allows to return the remainder of the division only.
2015-06-11 22:31:07 +02:00
Benjamin Morel
2c35d6fc5b
Fix negative numbers not supported by toString()
2015-06-08 00:12:50 +02:00
Benjamin Morel
e9da17c78d
Add getSign() method to BigInteger and BigDecimal
2015-06-07 14:48:49 +02:00
Benjamin Morel
2aabbe1a53
Missing division by zero test for BigDecimal::divideAndRemainder()
2015-06-05 22:19:20 +02:00
Benjamin Morel
536e6414e6
Performance optimizations
2015-06-05 22:17:20 +02:00
Benjamin Morel
c642d0d0c9
Change Money::dividedBy() parameter order
2015-06-04 21:45:13 +02:00
Benjamin Morel
908e73e8e4
unserialize() now throws an exception when called directly
...
This guarantees that immutability cannot be broken.
2015-06-04 12:14:42 +02:00
Benjamin Morel
53a61b46a7
Add BigDecimal::divideAndRemainder()
2015-06-02 22:08:56 +02:00
Benjamin Morel
49ea5a085e
Reworked Travis build matrix
...
Travis now supports merged code coverage reports, so we do not need to merge them ourselves.
2015-05-22 13:39:59 +02:00
Benjamin Morel
9ab6358fc2
min() and max() now use variadics
2015-05-22 13:19:08 +02:00
Benjamin Morel
4d18be75e1
Tests now run a single calculator instance at a time
2015-01-27 17:38:31 +01:00
Benjamin Morel
61968fcee9
Added BigInteger::power()
2014-09-01 19:10:04 +02:00
Benjamin Morel
09a4aa2895
Imposed a limit on the power() exponent
...
Just discovered that bcpow() on HHVM has a weird exponent limit of 2^27+1 (empirically determined), after which it triggers an "exponent too large in raise" error.
Anyway, an exponent of 1,000,000 is more than reasonable for most, if not all, use cases.
2014-09-01 18:38:00 +02:00
Benjamin Morel
d4a2a45f25
Fixed tests for HHVM with BCMath
2014-09-01 17:38:18 +02:00
Benjamin Morel
2b8ebcd55e
Changed tests namespace to Brick\Math\Tests
2014-08-31 14:24:10 +02:00
Benjamin Morel
5dfd5c45d0
Import from the incubator
2014-08-31 12:13:46 +00:00