Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Round to nearest 5
Message
De
25/01/2005 08:11:46
 
 
À
25/01/2005 08:05:22
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00980330
Message ID:
00980349
Vues:
31
>>Hi All,
>>
>>Having a bit of a brain freeze here...I have an integer between 0 and 100. I want to round it to the nearest integer wholly divisible by 5 i.e. 0,5,10,15,...95,100
>>
>>Sorry for the low quality challenge :)
>
>I am surprised by the complexity of some of the other solutions you received. Simply divide by 5, round, and then multiply by 5 again.
>
>
>? round(x / 5, 0) * 5
>
>
>This method would also work for fractions, e.g., round to the nearest 5 cents: replace 5 with 0.05.
>
>To round always down or always up, replace round() with ceiling() or floor().
>
>AFAIK, there is no built-in function to round to the "nearest whatever".


LOL! I told you I was having a brain freeze! Could'nt see the wood for the trees! LOL! Thanks Hilmar - my brain is back to it's usual sluggish speed :)
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform