PHP round() function is used to round a floating point number.
Syntax :
round(number,precision,mode);
Parameter,
number : Required. it is floating number.
precision : Optional. It specifies number of digits after the decimal point. Default is 0
mode : Optional. Below constant to specify the rounding mode in which rounding occurs.
- PHP_ROUND_HALF_UP : Rounds number away from zero when it is half way there, making 5.5 into 6 and -5.5 into -6.
- PHP_ROUND_HALF_DOWN : Rounds number towards zero when it is half way there, making 5.5 into 5 and -5.5 into -5.
- PHP_ROUND_HALF_EVEN : Rounds number towards the nearest even value when it is half way there, making both 5.5 and 6.5 into 6.
- PHP_ROUND_HALF_ODD : Rounds number towards the nearest odd value when it is half way there, making 5.5 into 5 and and 5.5 into 6.
Comments