1
0
mirror of https://github.com/danog/math.git synced 2024-11-30 04:19:31 +01:00
Commit Graph

154 Commits

Author SHA1 Message Date
Daniil Gentili
b2a3499218 Fixed mistakes in sqrt and its test 2016-07-30 00:54:56 +02:00
danogentili
e2a4969440 Added sqrt function and tests for it. Also added two() function to return a BigInteger of value 2. 2016-07-29 21:19:51 +02:00
danogentili
0fc7723baf Fixed mistake in documentation: according to http://php.net/manual/en/language.types.string.php, a string can store up to 2147483647 chars 2016-07-29 20:54:31 +02:00
Benjamin Morel
c29ab91bfa Fix documented return type of exceptions 2016-04-22 02:15:28 +02:00
Benjamin Morel
9bffcda216 Remove useless sentence in README
And this needed to be updated for each version.
2016-03-31 19:14:23 +02:00
Benjamin Morel
859ea90439 Fix incorrect optimization in dividedBy() - fixes #6 2016-03-31 18:54:32 +02:00
Benjamin Morel
3855223c72 Update license year 2016-03-29 00:35:49 +02:00
Benjamin Morel
6c094344b6 Fix typo in README
This closes #1
2015-09-07 20:14:50 +02:00
Benjamin Morel
a4a86af733 Add BigRational to composer keywords
[ci skip]
2015-08-06 13:24:52 +02:00
Benjamin Morel
0bb47e09ac Update README for 0.5.2
[ci skip]
2015-08-06 13:17:56 +02:00
Benjamin Morel
08c6979c62 BigDecimal::dividedBy()'s $scale parameter is optional again 2015-08-06 13:04:27 +02:00
Benjamin Morel
b326cd8e78 Fix copy/paste mistakes in docblocks 2015-07-14 12:00:15 +02:00
Benjamin Morel
d3262776f3 Improve README
[ci skip]
2015-07-13 13:43:20 +02:00
Benjamin Morel
70f66fc7c9 Version badge & information
[ci skip]
2015-07-05 13:13:10 +02:00
Benjamin Morel
c1bdb3b9b5 Add BigNumber::toScale()
This allows to convert any BigNumber to a BigDecimal of the given scale.
2015-07-05 13:07:10 +02:00
Benjamin Morel
0fa9a802c6 Add ApiGen config file
[ci skip]
2015-07-05 01:23:30 +02:00
Benjamin Morel
ef40d99979 Links to API documentation 2015-07-05 00:24:47 +02:00
Benjamin Morel
9a6d891ef8 Doc improvements
[ci skip]
2015-07-04 23:32:42 +02:00
Benjamin Morel
786810b891 Update README for version 0.5 2015-07-04 22:40:13 +02:00
Benjamin Morel
ef3e3b6ea7 Add negative tests for BigRational::toBigDecimal() 2015-07-04 13:40:42 +02:00
Benjamin Morel
f2f4f8d451 Remove BigRational::isFiniteDecimal()
This information can now be inferred by calling toBigDecimal() and catching the exception.
2015-07-04 13:35:15 +02:00
Benjamin Morel
ff9bc6e7bf Faster implementation of BigDecimal::withPointMovedRight()
Multiplying by powers of 10 can be achieved with string functions, without calling the calculator.
2015-07-04 01:57:49 +02:00
Benjamin Morel
147df4b73c Simplify BigDecimal::ofUnscaledValue() 2015-07-04 01:53:16 +02:00
Benjamin Morel
9017519b5d Improve docblock documentation 2015-07-04 01:51:59 +02:00
Benjamin Morel
aa43c637b7 Re-introduce rounding mode in BigInteger::dividedBy() 2015-07-04 01:35:02 +02:00
Benjamin Morel
640af2b413 Remove abstract operators from BigNumber, rename divide methods in BigDecimal
It turned out that there was no value in having a generic interface for operations, when every concrete class could really only accept instances of itself, and more importantly, would only return instances of itself. This was also a problem for division, that cannot be handled in the same way for BigInteger, BigDecimal and BigRational.

Methods changed in BigDecimal:

- dividedBy() is now exactlyDividedBy(), and always calculates the scale automatically
- dividedToScale() is now dividedBy(), and does not not make any assumption on the scale any more
2015-07-04 01:26:05 +02:00
Benjamin Morel
a32db93675 Move rounding code back to Calculator
It was a mistake to move it to BigDecimal, this is where it belongs.
2015-07-04 00:47:40 +02:00
Benjamin Morel
fd4feef6ce Remove composer self-update from Travis build
This command is not mandatory and is responsible of too many build errors.
2015-07-03 19:31:41 +02:00
Benjamin Morel
db16e619c3 Add BigDecimal::quotient() and remainder() methods 2015-07-03 18:05:02 +02:00
Benjamin Morel
271b619453 Rename BigDecimal::dividedAndRemainder() to quotientAndRemainder()
This is consistent with the naming of the BigInteger method.
2015-07-03 17:54:02 +02:00
Benjamin Morel
38a6b8c342 Add BigNumber::toInteger() and toFloat() methods
These methods are implemented by BigInteger, BigDecimal and BigRational.

- toInteger() returns an exact value or throws an exception
- toFloat() returns an approximate value
2015-07-03 17:22:43 +02:00
Benjamin Morel
45e3c3a463 Remove get prefix in method names
This improves overall consistency of method names in the project.
For example, it does not make sense to get the reciprocal of a BigRational using reciprocal(), but get its numerator using getNumerator().

List of renamed methods:

- BigNumber::getSign() => sign()
- BigDecimal::getUnscaledValue() => unscaledValue()
- BigDecimal::getScale() => scale()
- BigDecimal::getIntegral() => integral()
- BigDecimal::getFraction() => fraction()
- BigRational::getNumerator() => numerator()
- BigRational::getDenominator() => denominator()
2015-07-03 16:17:23 +02:00
Benjamin Morel
da27465258 Refactor tests 2015-07-03 16:03:58 +02:00
Benjamin Morel
751ba3592f Clean up unused import 2015-07-03 16:03:46 +02:00
Benjamin Morel
f2e4ac3f90 Fix wrongly documented return value 2015-07-03 15:52:24 +02:00
Benjamin Morel
97c7c45c51 All BigNumber subclasses now have zero(), one() and ten() factory methods
These methods are optimized for re-usability, and other methods now internally use them.
2015-07-03 15:36:57 +02:00
Benjamin Morel
2130b893c2 Split Calculator::div() into divQ(), divR() & divQR()
This will result in a slight performance improvement.
2015-07-03 14:12:46 +02:00
Benjamin Morel
5fe1176af9 BigDecimal::toBigRational() does not simplify the fraction any more 2015-07-03 13:46:48 +02:00
Benjamin Morel
050329ca23 Add quotient and remainder methods to BigRational 2015-07-03 13:32:13 +02:00
Benjamin Morel
10a4d13ea3 Better doc for basic arithmetic functions, of() in each subclass 2015-07-03 13:24:33 +02:00
Benjamin Morel
9418e2a337 Add BigDecimal::of() tests for float values INF and NAN 2015-06-30 13:45:51 +02:00
Benjamin Morel
9cd19d460b Fix typo in docblock 2015-06-28 23:40:14 +02:00
Benjamin Morel
1420202440 Exact division algorithm is now in BigDecimal::dividedBy()
BigRational::toBigDecimal() is now really just a proxy method to BigDecimal::dividedBy().
2015-06-28 22:51:02 +02:00
Benjamin Morel
5ccc6641b5 Fix typos 2015-06-28 19:29:25 +02:00
Benjamin Morel
7eeb9d3ca0 Parameters to BigNumber methods must be convertible to the current type
This applies to plus(), minus(), multipliedBy(), dividedBy().
2015-06-28 01:40:03 +02:00
Benjamin Morel
b3371daab2 BigDecimal::dividedByWithRounding() is now dividedToScale()
The $scale and $roundingMode parameters have been swapped.
2015-06-27 11:51:28 +02:00
Benjamin Morel
831d604169 Performance improvement on type conversions
Constructors of all BigNumber sub-classes are now accessible to each other via a proxy method in the parent class.
2015-06-27 01:18:32 +02:00
Benjamin Morel
7376e828c2 Remove BigDecimal::dividedByExact(), now implemented by dividedBy() 2015-06-26 23:47:44 +02:00
Benjamin Morel
d0a91c6be1 Add missing BigInteger tests 2015-06-26 13:41:47 +02:00
Benjamin Morel
baba83c721 Remove dead code Calculator::sign() 2015-06-26 13:28:24 +02:00