This repository has been archived by the owner on Dec 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from codisart/add-arctan-method
[TECH] Add the arctan method. Thanks to @codisart .
- Loading branch information
Showing
2 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Litipk\BigNumbers\Decimal as Decimal; | ||
|
||
/** | ||
* @group arctan | ||
*/ | ||
class DecimalArctanTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function arctanProvider() { | ||
// Some values provided by wolframalpha | ||
return [ | ||
['0.154', '0.15279961393666', 14], | ||
['0', '0', 17], | ||
['-1', '-0.78539816339744831', 17], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider arctanProvider | ||
*/ | ||
public function testSimple($nr, $answer, $digits) | ||
{ | ||
$x = Decimal::fromString($nr); | ||
$arctanX = $x->arctan($digits); | ||
|
||
$this->assertTrue( | ||
Decimal::fromString($answer)->equals($arctanX), | ||
"The answer must be " . $answer . ", but was " . $arctanX | ||
); | ||
} | ||
|
||
} |