Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Remove hardcoded dependency #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
441 changes: 223 additions & 218 deletions src/Decimal.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/DecimalConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @author Andreu Correa Casablanca <castarco@litipk.com>
*/
final class DecimalConstants
class DecimalConstants
{
/** @var Decimal */
private static $ZERO = null;
Expand Down
1 change: 1 addition & 0 deletions tests/Decimal/DecimalArccosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function arccosProvider() {
// Some values provided by wolframalpha
return [
['0.154', '1.41618102663394', 14],
['0.154', '1.41618102663393517247013425592456', null],
['1', '0', 17],
['-1', '3.14159265358979324', 17],
];
Expand Down
1 change: 1 addition & 0 deletions tests/Decimal/DecimalArccotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function arccotProvider() {
// Some values provided by wolframalpha
return [
['0.154', '1.41799671285823', 14],
['0.154', '1.41799671285823208779719313430598', null],
['0', '1.57079632679489662', 17],
['-1', '-0.78540', 5],
];
Expand Down
1 change: 1 addition & 0 deletions tests/Decimal/DecimalArccscTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function arccscProvider() {
// Some values provided by wolframalpha
return [
['25.546', '0.03915507577327', 14],
['25.546', '0.03915507577326592075276730624736', null],
['1.5', '0.729728', 6],
['1', '1.57079632679489662', 17],
['-1', '-1.57079632679489662', 17],
Expand Down
1 change: 1 addition & 0 deletions tests/Decimal/DecimalArcsecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function arcsecProvider() {
// Some values provided by wolframalpha
return [
['25.546', '1.53164125102163', 14],
['25.546', '1.53164125102163069847855438539239', null],
['1.5', '0.841068', 6],
['1', '0', 17],
['-1', '3.14159265358979324', 17],
Expand Down
1 change: 1 addition & 0 deletions tests/Decimal/DecimalArcsinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function arcsinProvider() {
// Some values provided by wolframalpha
return [
['0.154', '0.15461530016096', 14],
['0.154', '0.15461530016096144676118743571519', null],
['1', '1.57079632679489662', 17],
['-1', '-1.57079632679489662', 17],
];
Expand Down
1 change: 1 addition & 0 deletions tests/Decimal/DecimalArctanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function arctanProvider() {
// Some values provided by wolframalpha
return [
['0.154', '0.15279961393666', 14],
['0.154', '0.15279961393666453143412855733377', null],
['0', '0', 17],
['-1', '-0.78539816339744831', 17],
];
Expand Down
3 changes: 2 additions & 1 deletion tests/Decimal/DecimalCosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function cosProvider() {
// Some values provided by Mathematica
return [
['1', '0.54030230586814', 14],
['1', '0.54030230586813971740093660744298', null],
['123.123', '-0.82483472946164834', 17],
['15000000000', '-0.72218064388924347683', 20]
];
Expand All @@ -23,7 +24,7 @@ public function cosProvider() {
public function testSimple($nr, $answer, $digits)
{
$x = Decimal::fromString($nr);
$cosX = $x->cos((int)$digits);
$cosX = $x->cos($digits);

$this->assertTrue(
Decimal::fromString($answer)->equals($cosX),
Expand Down
3 changes: 2 additions & 1 deletion tests/Decimal/DecimalCosecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function cosecProvider() {
// Some values provided by Mathematica
return [
['1', '1.18839510577812', 14],
['1', '1.18839510577812121626159945237455', null],
['123.123', '-1.76874094322450309', 17],
['15000000000', '1.44570405082842149818', 20]
];
Expand All @@ -23,7 +24,7 @@ public function cosecProvider() {
public function testSimple($nr, $answer, $digits)
{
$x = Decimal::fromString($nr);
$cosecX = $x->cosec((int)$digits);
$cosecX = $x->cosec($digits);

$this->assertTrue(
Decimal::fromString($answer)->equals($cosecX),
Expand Down
5 changes: 3 additions & 2 deletions tests/Decimal/DecimalCotanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function cotanProvider() {
// Some values providede by mathematica
return [
['1', '0.64209261593433', 14],
['1', '0.64209261593433070300641998659427', null],
['123.123', '1.45891895739232371', 17],
['15000000000', '-1.04405948230055701685', 20]
];
Expand All @@ -37,8 +38,8 @@ public function testSimple($nr, $answer, $digits)
*/
public function testCotanPiDiv()
{
$PI = DecimalConstants::PI();
$PI->cotan();
$pi = DecimalConstants::pi();
$pi->cotan(30);
}

}
3 changes: 2 additions & 1 deletion tests/Decimal/DecimalSecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function SecProvider() {
// Some values provided by Mathematica
return [
['5', '3.52532008581609', 14],
['5', '3.52532008581608840670180105996324', null],
['456.456', '-1.66172995090378344', 17],
['28000000000', '-1.11551381955633891873', 20],
];
Expand All @@ -23,7 +24,7 @@ public function SecProvider() {
public function testSimple($nr, $answer, $digits)
{
$x = Decimal::fromString($nr);
$secX = $x->sec((int)$digits);
$secX = $x->sec($digits);

$this->assertTrue(
Decimal::fromString($answer)->equals($secX),
Expand Down
1 change: 1 addition & 0 deletions tests/Decimal/DecimalSinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function sinProvider() {
// Some values providede by mathematica
return [
['1', '0.84147098480790', 14],
['1', '0.84147098480789650665250232163030', null],
['123.123', '-0.56537391969733569', 17],
['15000000000', '0.69170450164193502844', 20]
];
Expand Down
5 changes: 3 additions & 2 deletions tests/Decimal/DecimalTanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function tanProvider() {
// Some values providede by mathematica
return [
['1', '1.55740772465490', 14],
['1', '1.55740772465490223050697480745836', null],
['123.123', '0.68543903342472368', 17],
['15000000000', '-0.95779983511717825557', 20]
];
Expand All @@ -37,8 +38,8 @@ public function testSimple($nr, $answer, $digits)
*/
public function testTanPiTwoDiv()
{
$PiDividedByTwo = DecimalConstants::PI()->div(Decimal::fromInteger(2));
$PiDividedByTwo->tan();
$piDividedByTwo = DecimalConstants::pi()->div(Decimal::fromInteger(2));
$piDividedByTwo->tan(30);
}

}