Math Function

1. abs => it returns the absolute value of Number...
Syntax : abs(x)
<?php
echo(abs(6.7) . "<br />"); //6.7
echo(abs(-3) . "<br />"); //3 echo(abs(3)); //3
?>
2. ord => returns highest integer value by rounding .
Syntax : ceil(x)
3. floor => The function returns the value of a number rounded DOWNWARDS to the nearestinteger.
Syntax : floor(x)
4. round => The function rounds a number to the nearest integer.
Syntax : round(x)

Ord()
Floor()
Round()
<?php
echo(ceil(0.60) . "<br />"); //1
echo(ceil(0.40) . "<br />"); //1
echo(ceil(5) . "<br />"); //5
echo(ceil(5.1) . "<br />"); //6
echo(ceil(-5.1) . "<br />"); // -5 echo(ceil(-5.9)) // -5
?>
<?php
echo(floor(0.60) . "<br />"); //0
echo(floor(0.40) . "<br />"); //0
echo(floor(5) . "<br />"); //5
echo(floor(5.1) . "<br />"); //5
echo(floor(-5.1) . "<br />"); //-6
echo(floor(-5.9)); //-6
?>
<?php
echo(round(0.60) . "<br />"); //1
echo(round(0.50) . "<br />"); //1
echo(round(0.49) . "<br />"); //0
echo(round(-4.40) . "<br />"); //-4 echo(round(-4.60)) //-5
?>

No comments:

Post a Comment

=>Advanced Java Programming (J2EE)

1.  Syllabus 2. Unit Wise Question/Material 3. Paper 4. Previous Paper