public function testAddLargeIntegerToADecimalSmallerThanOne() { $x = \MyOddWeb\BigNumber("123456789123456789123456789"); $y = \MyOddWeb\BigNumber("0.0000000002"); $z = $y->Add($x)->ToString(); $this->assertSame("123456789123456789123456789.0000000002", $z); }
public function testSqrtOfZeroPointFive() { $x = \MyOddWeb\BigNumber(0.5); $y = $x->Sqrt(10); // 0.70710678118654752440084436210485 $z = $y->ToString(); $this->assertSame("0.7071067812", $z); }
public function testPositiveNumberDividedByNegativeNumber() { $x = \MyOddWeb\BigNumber(20); $z = $x->Div(-2)->ToString(); $this->assertSame("-10", $z); $x = \MyOddWeb\BigNumber(100); $z = $x->Div(-100)->ToString(); $this->assertSame("-1", $z); $x = \MyOddWeb\BigNumber(1000000); $z = $x->Div(-244.140625)->ToString(); // 4096 $this->assertSame("-4096", $z); }
public function testNegativePiToDegree() { $rad = \MyOddWeb\BigNumber(\MyOddWeb\BigNumber::pi())->ToDegree(10); $rad->Mul(-1); $z = $rad->ToString(); $this->assertSame("-180", $z); }
public function testSubtractSmallNumberToBecomeLargeInteger() { $x = \MyOddWeb\BigNumber("123456789123456789123456789123456789.000002"); $y = \MyOddWeb\BigNumber("0.000002"); $z = $x->Sub($y)->ToString(); $this->assertSame("123456789123456789123456789123456789", $z); }