Gen. partnerAlgotech

PHP function round()

Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default). Note: PHP doesn't handle strings like "12,300.2" correctly by default. See converting from strings.

|
September 11, 2019

Availability in PHP 4.0

Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default). Note: PHP doesn't handle strings like "12,300.2" correctly by default. See converting from strings.

Parameters

Parameter Data type Default value Note
$val float not The value to round
$precision int 0, The optional number of decimal digits to round to.
$mode int PHP_ROUND_HALF_UP One of PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EVEN, or PHP_ROUND_HALF_ODD.

Return values

float

The rounded value

Other resources

Official documentation of the round function

Loading comments...

Stay in the loop

Subscribe to our newsletter and get the latest cybersecurity news delivered straight to your inbox.

Your data is safe. You can unsubscribe from the newsletter at any time.