Benjamin Morel
1ade407e23
Remove BigRational::get(), redundant with of()
2015-06-22 22:29:30 +02:00
Benjamin Morel
89a43d49a6
Precision about rational numbers
2015-06-22 22:15:02 +02:00
Benjamin Morel
27bc623b70
BigNumber::of() now throws NumberFormatException instead of InvalidArgumentException
...
This allows to catch all of() exceptions with the parent, ArithmeticException.
2015-06-22 22:13:19 +02:00
Benjamin Morel
d6aa1007a9
Introducing a specific RoundingNecessaryException
2015-06-22 21:53:32 +02:00
Benjamin Morel
ed8e1075e2
Introducing a specific DivisionByZeroException
2015-06-22 14:12:40 +02:00
Benjamin Morel
7680dcf634
Move ArithmeticException to an Exception sub-namespace
2015-06-22 13:57:47 +02:00
Benjamin Morel
8b2d6781cd
BigInteger, BigDecimal and BigRational are now final
2015-06-22 12:51:21 +02:00
Benjamin Morel
c343e0aeb9
Merge of() factory methods in BigNumber
2015-06-22 12:50:44 +02:00
Benjamin Morel
d047282ec9
Disable PHPUnit globals backup
...
This is not useful for this test suite, and uselessly affects performance.
2015-06-22 12:41:35 +02:00
Benjamin Morel
41c34b1014
Add tests for BigDecimal::of() with leading zeros in exponent
2015-06-21 15:13:54 +02:00
Benjamin Morel
65d4dd75d6
Rename BigRational factory methods
...
- `BigRational::parse()` is now `of()`
- `BigRational::of()` is now `nd()`
This keeps BigRational in line with BigInteger and BigDecimal, whose `of()` factory method accepts a single parameter.
The new way to create a BigRational from two numbers is now called `nd()` for numerator/denominator.
2015-06-21 14:48:26 +02:00
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
3fd07960ef
Fix parse() method on latest PHP 7
...
The behaviour of substr() has been changed following the fix of this bug:
https://bugs.php.net/bug.php?id=62922
By this commit:
257054e81d
2015-06-21 14:14:34 +02:00
Benjamin Morel
3afa5cef7b
Simplification of NativeCalculator::init()
2015-06-21 14:01:44 +02:00
Benjamin Morel
1c7902cd48
Fix NativeCalculator::cmp() implementation
...
This was returning negative numbers other than -1 and positive numbers other than 1.
2015-06-21 13:55:44 +02:00
Benjamin Morel
32e898a3c2
Add release process notes
...
[ci skip]
2015-06-20 23:54:06 +02:00
Benjamin Morel
f3e4b2032c
Faster cmp() implementation for NativeCalculator
2015-06-20 22:59:39 +02:00
Benjamin Morel
20030b6798
Fix documentation referring to Decimal instead of BigDecimal
2015-06-20 13:45:47 +02:00
Benjamin Morel
c1aa379479
BigNumber is now an abstract class
...
This allows the factorization of most comparison & sign functions in a single place.
Only `compareTo()` and `getSign()` are now abstract, the others methods are based on these two.
2015-06-20 13:37:10 +02:00
Benjamin Morel
5d65ef08cc
Comparison and sign methods are now part of the BigNumber interface
2015-06-20 13:25:55 +02:00
Benjamin Morel
2619c02fd6
Add __toString() to the BigNumber interface
2015-06-20 11:01:46 +02:00
Benjamin Morel
ade40b841b
Simplify the maxDecimalPlaces inferring code
2015-06-20 10:59:17 +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
c4e2867049
CS fix: missing space
2015-06-20 00:36:21 +02:00
Benjamin Morel
8f296871f2
Add BigRational::toBigDecimal()
2015-06-20 00:36:01 +02:00
Benjamin Morel
f4e1f9b5ff
Add specific version for composer
2015-06-20 00:11:24 +02:00
Benjamin Morel
572247967d
Add precisions about scales
2015-06-19 22:06:31 +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
6e3257fb93
Make RoundingMode non-instantiable
2015-06-18 09:06:30 +02:00
Benjamin Morel
ac691e01e5
Add BigDecimal::stripTrailingZeros()
2015-06-17 00:40:31 +02:00
Benjamin Morel
0a8b269952
README notes about BigRational
2015-06-13 00:14:37 +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
1ff8b8b2d3
More notes about serializing
2015-06-12 12:59:24 +02:00
Benjamin Morel
5533b2aa36
Move rounding code from Calculator to BigDecimal
2015-06-12 10:25:09 +00: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
de917b9e17
Add license badge
2015-06-07 15:18:07 +02:00
Benjamin Morel
427faf03dc
Reverted comment on HHVM
...
This component does not make use of typed variadics, so HHVM is already supported.
2015-06-07 15:06:25 +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