-
Notifications
You must be signed in to change notification settings - Fork 0
/
UseNumber.php
24 lines (20 loc) · 1.37 KB
/
UseNumber.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Macocci7\PhpMathInteger\Number;
$n = new Number();
echo "Is 1 int? - " . ($n->isInt(1) ? 'Yes' : 'No') . ".\n";
echo "Are [ 1, 2, 3, ] all int? - " . ($n->isIntAll([ 1, 2, 3, ]) ? 'Yes' : 'No') . ".\n";
echo "Is 1 natural? - " . ($n->isNatural(1) ? 'Yes' : 'No') . ".\n";
echo "Are [ 1, 2, 3, ] all natural? - " . ($n->isNaturalAll([ 1, 2, 3, ]) ? 'Yes' : 'No') . ".\n";
echo "Is 1.2 float? - " . ($n->isFloat(1.2) ? 'Yes' : 'No') . ".\n";
echo "Are [ -2.1, 0.0, 1.2, ] all float? - " . ($n->isFloatAll([ -2.1, 0.0, 1.2, ]) ? 'Yes' : 'No') . ".\n";
echo "Is 1.2 number? - " . ($n->isNumber(1.2) ? 'Yes' : 'No') . ".\n";
echo "Are [ -2, 0.1, 3, ] all number? - " . ($n->isNumberAll([ -2, 0.1, 3, ]) ? 'Yes' : 'No') . ".\n";
echo "Is 0.1 fraction? - " . ($n->isFraction(0.1) ? 'Yes' : 'No') . ".\n";
echo "Are [ -0.99, 0.1, 0.99, ] all fraction? - " . ($n->isFractionAll([ -0.99, 0.1, 0.99, ]) ? 'Yes' : 'No') . ".\n";
echo "Sign of -2.5 is " . $n->sign(-2.5) . ".\n";
echo "Integer part of 3.14 is " . $n->int(3.14) . ".\n";
echo "Fractional part of 3.14 is " . $n->fraction(3.14) . ".\n";
echo "-3th digit of 123.4567 is " . $n->nthDigit(-3, 123.4567) . ".\n";
echo "Number of digits -123.4567 is " . $n->numberOfDigits(-123.4567) . ".\n";
echo "Number of fractional digits -12.3456 is " . $n->numberOfFractionalDigits(-12.3456) . ".\n";