Useful Numeric Functions in PHP

0

- Advertisement -

There are many functions related to numbers.like Useful Numeric Functions in PHP ,Mathematical Functions in PHP  Here are a few of the most common and useful:

abs() : 

Returns the absolute value of the number.
Syntax: 

Example;

Output Will be :
5
5
8.5
8.5

pi() :

Return the value of pi.
Syntax:

Example :

Output will be
3.1415926535898

round() :

Rounds a number to nearest integer.
Syntax

$number : Number which you wnat to round
$precision : Optional Parameter. It specifies the number of decimal digits to round to. The default value of this parameter is zero.
$mode : Rounding mode.
Possible values :
PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EVEN, PHP_ROUND_HALF_ODD.
Example :

sqrt() :

Retruns the sqaure root of a number.
Syntax : 

Example :

- Advertisement -

Leave A Reply

Your email address will not be published.