Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
5616 connectés 

  FORUM HardWare.fr
  Programmation
  Shell/Batch

  Arrondi à 10 près ? awk '{printf ("%d\n", $5+1)}' ?

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Arrondi à 10 près ? awk '{printf ("%d\n", $5+1)}' ?

n°1958950
tabasko
Posté le 20-01-2010 à 11:20:04  profilanswer
 

Bonjour à tous,
 
Je souhaite faire un arrondi à 10 près.
Je ne sais scripter que l'arrondi traditionnel comme ceci :  awk '{printf ("%d\n", $5+1)}' toto.txt
 
Pour le moment j'obtiens ceci :
172
24
35
157
56
23
37
37
54
147
 
Il me faudrait  
172 -> 170
24 -> 20
35 -> 40
157  -> 160
56 -> 60
23 -> 20
37 -> 40
37 -> 40
54 -> 50
147 -> 150
etc...
 
Merci pour vos lumières ...

mood
Publicité
Posté le 20-01-2010 à 11:20:04  profilanswer
 

n°1958987
olivthill
Posté le 20-01-2010 à 12:15:23  profilanswer
 

Est-ce bien $5 (le cinquième champ) ou $1 (le premier champ) ?
Si c'est $5, faire :

awk '{printf ("%d\n", int(($5 + 5) / 10) * 10)}' toto.txt

n°1958993
tabasko
Posté le 20-01-2010 à 12:21:39  profilanswer
 

Nickel !!!
Merci !
Oui champ 5.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Shell/Batch

  Arrondi à 10 près ? awk '{printf ("%d\n", $5+1)}' ?

 

Sujets relatifs
[RESOLU]Arrondi à partir d'une chaine de caractèreVBA :Garder les arrondi avec les pourcentages
[VB6] Problème arrondi calcul validité IBANBord arrondi <input> ?
Arrondi d'un point floattant[Access] fonction arrondi sup
[MYSQL 5.0] datetime arrondifork() empêche les printf ?!
Cadre Arrondi CSS [plus clair]float double et arrondi
Plus de sujets relatifs à : Arrondi à 10 près ? awk '{printf ("%d\n", $5+1)}' ?


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)