Les Snippets

Connexion

Convertir un nombre en taille (Ko,Mo,Go)

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 25/03/2006 23:35:22 et initié par EBArtSoft [Liste]
Date de mise à jour : 05/08/2006 14:25:59
Vue : 13031
Catégorie(s) : Fichier / Disque, Trucs & Astuces, Chaîne de caractères
Langage sélectionné : Perl
Langages dispo pour ce code :
- VB6, VBA
- Delphi 5
- PHP 3, PHP 4, PHP 5
- PHP 3, PHP 4, PHP 5
- Perl
- Voir tous les langages pour ce code snippet



Langage : Perl
Date ajout : 04/06/2007
Posté par coucou747 [Liste]
sub int2taille
{
    $i=@_[0];
    $b=@_[1];
    $o=$i%1024;
    $k=int(($i/$b)%$b);
    $m=int(($i/$b/$b)%$b);
    $g=int(($i/$b/$b/$b));
    return (($g!=0)?($g.' Go '.$m.' Mo '.$k.' Ko '.$o.' o'):($m!=0)?($m.' Mo '.$k.' Ko '.$o.' o'):(($k!=0)?$k.' Ko '.$o.' o':$o.' o'));
}
print int2taille(4000, 1024);