Recherche sur les Noms des fonctions php/mysql
round()
Définition
-Description
float round
( float $val
[, int $precision
] )
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.
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 en PHP 4.
Liste de paramètres
- val
-
La valeur à arrondir
- precision
-
Le nombre optionnel de décimales à arrondir ; par défaut, 0
Valeurs de retour
La valeur arrondie
Exemples
Exemple #1 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
?>
Bouts de code utilisant la fonction round()
<?php /* ... */
$taux = round(($nb_word_text_bold*
100)/$nb_word_content_origin,2);// Taux de mots en gras sur la ligne "content"
//Si l'URL n'est pas notre domaine et taux > 40 on insert
/* ... */ ?>
<?php /* ... */
return false;
$this->metrics['tps'] = round( ($this->metrics['tweets'] - $this->metrics[
'last_tweets']) / $this->config['streaming_metrics_interval'], 2);
/* ... */ ?>
<?php /* ... */
// calcul l'image sur la base hauteur
$thumb_width = round($thumb_height * $aspect_ratio);
// imagecreatefromstring va automatiquement detecter le type de l'image
/* ... */ ?>
<?php /* ... */
$width = 100 / $nbre_colonne;
$width = round ($width);
$count = 0;
/* ... */ ?>
<?php /* ... */
// arrondi le résultat
$resultat_mot = round($resultat_mot);
if ($resultat_mot <= $nombre_de_mots_par_separateur) {
/* ... */ ?>
Connexion
Les fonctions
Références
- abs
- acos
- acosh
- asin
- asinh
- atan2
- atan
- 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
- log10
- log1p
- log
- max
- min
- mt_getrandmax
- mt_rand
- mt_srand
- octdec
- pi
- pow
- rad2deg
- rand
- round
- sin
- sinh
- sqrt
- srand
- tan
- tanh





