8.65 Mathématiques
8 Référence des fonctions
Manuel PHP
. Introduction . Pré-requis . Installation . Configuration à l'exécution . Types de ressources . Constantes pré-définies . abs . acos . acosh . asin . asinh . atan . atan2 . atanh . base_convert . bindec . ceil . cos . cosh . decbin . dechex . decoct . deg2rad . exp . expm1 . floor . fmod . getrandmax . hexdec . hypot . is_finite . is_infinite . is_nan . lcg_value . log . log10 . log1p . max . min . mt_getrandmax . mt_rand . mt_srand . octdec . pi . pow . rad2deg . rand ->round . sin . sinh . sqrt . srand . tan . tanh
|
8.65.48 round()Arrondi[ Exemples avec round ] PHP 3, PHP 4, PHP 5
float
round (
float
val
,
int
precision
)
round
retourne la valeur arrondie de
val
à la précision
precision
(nombre de chiffres après la virgule). Le paramètre
precision
peut être négatif ou
NULL
:
c'est sa valeur par défaut.
| Exemple avec round |
<?php echo round(3.4); // 3 echo round(3.5); // 4 echo round(3.6); // 4 echo round(3.6, 0); // 4 echo round(1.95583, 2); // 1.96 echo round(1241757, -3); // 1242000 echo round(5.045, 2); // 5.05 echo round(5.055, 2); // 5.06 ?>
|
| Note | |
PHP ne gère pas correctement les chaînes telles que
"12 300,2"
, par défaut. Reportez-vous à
la conversion de
chaînes .
|
| Note | |
Le paramètre
precision
a été introduit
depuis PHP 4.
|
Voir aussi
ceil
,
floor
et
number_format
.
|