Skip to content

04. Trigonometry

Jordan LeDoux edited this page Jan 16, 2017 · 6 revisions

Working with DecimalInterface

Trigonometry methods are only available on objects which implement DecimalInterface. If you want to do trigonometry functions on an object that implement FractionInterface, calling the asDecimal() method will return the numerator divided by the denominator as an instance of ImmutableNumber which implements the DecimalInterface.

sin(int $precision = null, bool $round = true): self

This function applies the sin function to the current Value. If $precision is null, the precision setting of the object is used. If a precision of greater than 99 is supplied as an argument, or if the object has a precision of greater than 99, the precision is silently reduced to 99.

<?php

use Samsara\Fermat\Values\ImmutableNumber;

$four = new ImmutableNumber(4);
$largeInt = new ImmutableNumber('1000000000000000000000000000');

echo $four->sin();       // Prints: "-0.7568024953"
echo $largeInt->sin(15); // Prints: "0.718063496139118"

Clone this wiki locally