php round() function


  Translation results:

英[raʊnd] 美[raʊnd]

adj. Round; arc-shaped; plump, fat; integer

adv. Everywhere; around; roundabout ; in the opposite direction

prep.approximately; around, surrounding; (indicating position) around; nearby

n. circle, circle; cycle; round object, spherical object; (Meeting) One round

Third person singular: rounds Plural: rounds Present participle: rounding Past tense: rounded Past participle: rounded Comparative: rounder Superlative: roundest

php round() functionsyntax

Function: The round() function is used to round floating point numbers

Syntax: round(X,prec)

Parameters:

ParametersDescription
XTo be done Processed numbers
precSpecify the number of digits after the decimal point

Description: Return the result of rounding parameter X according to the number of digits after the decimal point prec. prec can be a negative number or 0, and 0 is the default value.

php round() functionexample

<?php
$i = 1.56;
$i = round($i,2);
$j = 5.25;
$j = round($j,-1);
$k = -5.35;
$k = round($k);
echo $i."*****".$j."*****".$k;
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

1.56*****10*****-5
<?php
$i = -5.6;
$j = round($i);
echo $j;
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

-6

Popular Recommendations

Home

Videos

Q&A