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.15 base_convert()Convertit un nombre entre des bases arbitraires[ Exemples avec base_convert ] PHP 3 >= 3.0.6, PHP 4, PHP 5
string
base_convert (
string
number
,
int
frombase
,
int
tobase
)
base_convert
retourne une chaîne contenant
l'argument
number
représenté
dans la base
tobase
. La base de
représentation de
number
est
donnée par
frombase
.
frombase
et
tobase
doivent être compris entre 2 et 36 inclus. Les chiffres
supérieurs à 10 des bases supérieures
à 10 seront représentés par les lettres
de A à Z, avec A = 10 et Z = 36.
| Exemple avec base_convert |
<?php $hexadecimal = 'A37334'; echo base_convert($hexadecimal, 16, 2); ?>
|
| Attention | |
base_convert
perdra la précision sur les grands nombres dû
à la propriété interne des types "double" et "float".
Merci de regarder la section sur les
nombres à virgule flottante dans
ce manuel pour plus d'informations.
|
|