Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Vilhelm-Ion Praisach
  Where is Vilhelm-Ion Praisach?
 Resita
 Romania
 Vilhelm-Ion Praisach
 To: barney guna
  Where is barney guna?
 BANALORE
 India
 barney guna
 Tags
Subject: RE: Rounding off to nearest 10
Thread ID: 394147 Message ID: 394164 # Views: 77 # Ratings: 3
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Tuesday, December 31, 2013 4:24:16 AM         
   


> Dear all,
>
> Please help me with this one !
>
> I need to convert a figure (numeric) to the nearest 10, using round I suppose,
>
> For eg., I get an answer/total of 89,764 it should be converted to 89,770
>
> I have tried round(ggg,10) but it does not work...
>
> Thank you!
>
> Barney

You may use ROUND(), but it rounds to the nearest not to the upper tenth.
nxx=89764
? ROUND(nxx,-1)
gives 89760.

You can use a trick
? ROUND(nxx+5,-1)
who gives 89770
but, unfortunately, fails for nxx=89760 because it gives 89770.

So it be must more elaborated.
The final solution is :

? ROUND(IIF(MOD(nxx,10)=0,nxx,nxx+5),-1)


In conclusion, Mr. Stefan Wuebbe's solution is simpler and clearer

My respects

ENTIRE THREAD

Rounding off to nearest 10 Posted by barney guna @ 12/31/2013 12:17:13 AM
RE: Rounding off to nearest 10 Posted by Stefan Wuebbe @ 12/31/2013 1:01:45 AM
RE: Rounding off to nearest 10 Posted by barney guna @ 12/31/2013 3:05:47 AM
RE: Rounding off to nearest 10 Posted by barney guna @ 1/2/2014 8:13:00 AM
RE: Rounding off to nearest 10 Posted by Stefan Wuebbe @ 1/2/2014 8:25:14 AM
RE: Rounding off to nearest 10 Posted by David Mustakim @ 1/2/2014 8:25:52 AM
RE: Rounding off to nearest 10 Posted by Glen Villar @ 12/31/2013 1:16:20 AM
RE: Rounding off to nearest 10 Posted by barney guna @ 12/31/2013 3:13:10 AM
RE: Rounding off to nearest 10 Posted by Vilhelm-Ion Praisach @ 12/31/2013 12:12:34 PM
RE: Rounding off to nearest 10 Posted by barney guna @ 1/2/2014 8:13:34 AM
RE: Rounding off to nearest 10 Posted by barney guna @ 1/2/2014 8:13:20 AM
RE: Rounding off to nearest 10 Posted by Vilhelm-Ion Praisach @ 12/31/2013 4:24:16 AM
RE: Rounding off to nearest 10 Posted by Gene Wirchenko @ 12/31/2013 7:48:57 PM
RE: Rounding off to nearest 10 Posted by Vilhelm-Ion Praisach @ 12/31/2013 8:59:39 PM
RE: Rounding off to nearest 10 Posted by David Mustakim @ 12/31/2013 9:15:55 PM
RE: Rounding off to nearest 10 Posted by Vilhelm-Ion Praisach @ 12/31/2013 9:23:07 PM
RE: Rounding off to nearest 10 Posted by David Mustakim @ 12/31/2013 9:25:48 PM
RE: Rounding off to nearest 10 Posted by Anders Altberg @ 1/1/2014 3:35:51 PM
RE: Rounding off to nearest 10 Posted by Vilhelm-Ion Praisach @ 1/1/2014 4:31:45 PM
RE: Rounding off to nearest 10 Posted by barney guna @ 1/2/2014 8:14:11 AM
RE: Rounding off to nearest 10 Posted by Anders Altberg @ 1/4/2014 1:25:13 AM
RE: Rounding off to nearest 10 Posted by barney guna @ 1/2/2014 8:13:52 AM
RE: Rounding off to nearest 10 Posted by Gene Wirchenko @ 12/31/2013 10:59:47 PM
RE: Rounding off to nearest 10 Posted by barney guna @ 1/2/2014 8:12:46 AM
RE: Rounding off to nearest 10 Posted by David Mustakim @ 1/2/2014 9:45:35 AM
RE: Rounding off to nearest 10 Posted by Tore Bleken @ 1/2/2014 9:54:32 AM
RE: Rounding off to nearest 10 Posted by Luis Maria Guayan @ 1/6/2014 8:39:08 PM