PHP/Math/Math Functions
Содержание
Difference between ceil and floor
<?
$my_double = 4.7;
$my_int = ceil($my_double);
echo($my_int);
$my_double = -4.7;
$my_int = floor($my_double);
echo($my_int);
?>
Exp
<?
$test_449 = 449.0;
$test_449 = pow(10, exp(log(log10($test_449))));
print("test_449 is $test_449<BR>");
?>
Floor in action
<?
$my_int = floor(4.7);
echo($my_int);
$my_int = floor(-4.7);
echo($my_int);
?>
Get the Power
<?
echo pow(19, 5);
?>
rand demo
<?
echo rand(0,576);
?>
Round in action
<?
$my_int = round(4.7);
echo($my_int);
$my_int = round(-4.7);
echo($my_int);
$my_int = round(-4.5);
echo($my_int);
?>
Using the arbitrary-precision functions for exact integer arithmetic
<?
for ($x = 1; $x < 25; $x++) {
print("$x to the $x power is " . bcpow($x, $x) . "<BR>");
}
?>