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

Commit fd71051

Browse files
committed
Add cotan function for infinite decimal.
1 parent 5f81388 commit fd71051

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/InfiniteDecimal.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,14 @@ public function tan($scale = null)
281281
);
282282
}
283283

284+
public function cotan($scale = null)
285+
{
286+
throw new \DomainException(($this === self::$pInf) ?
287+
"Cotangent function hasn't limit in the positive infinite." :
288+
"Cotangent function hasn't limit in the negative infinite."
289+
);
290+
}
291+
284292
/**
285293
* @return boolean
286294
*/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use Litipk\BigNumbers\InfiniteDecimal as InfiniteDecimal;
4+
5+
/**
6+
* @group cotan
7+
*/
8+
class InfiniteDecimalCotanTest extends PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @expectedException \DomainException
12+
* @expectedExceptionMessage Cotangent function hasn't limit in the positive infinite.
13+
*/
14+
public function testFinitePositiveInfiniteCotan()
15+
{
16+
InfiniteDecimal::getPositiveInfinite()->cotan();
17+
}
18+
19+
/**
20+
* @expectedException \DomainException
21+
* @expectedExceptionMessage Cotangent function hasn't limit in the negative infinite.
22+
*/
23+
public function testFiniteNegativeInfiniteCotan()
24+
{
25+
InfiniteDecimal::getNegativeInfinite()->cotan();
26+
}
27+
}

0 commit comments

Comments
 (0)