Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: David Mustakim
  Where is David Mustakim?
 Jakarta
 Indonesia
 David Mustakim
 To: Vilhelm-Ion Praisach
  Where is Vilhelm-Ion Praisach?
 Resita
 Romania
 Vilhelm-Ion Praisach
 Tags
Subject: RE: Rounding off to nearest 10
Thread ID: 394147 Message ID: 394230 # Views: 44 # Ratings: 0
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Tuesday, December 31, 2013 9:15:55 PM         
   


> >
> > Add 4 instead.
> >
> > You will still have to account for negative numbers.
> >
> > [snip]
> >
> >
> > I looked at his code. Barney stated that he is generating bills. What about a negative bill (say cancelling a bill)? Stefan's code would round the wrong way for negative numbers because ceil() is non-symmetric about 0.
> >
> > For symmetric about 0, this will do it:
> >
> >
> > procedure round10
> > lparameters n
> > 
> >    return round(abs(n)+4,-1)*sign(n)
> > 
> >    endproc
> > 

> >
> > Sincerely,
> >
> > Gene Wirchenko
>
> Good point. Thank you!
> Both Stefan Wuebbe and Glen Villar solutions can be adapted similarly.
>
? SIGN(a)*(ABS(a) - MOD(ABS(a),-10))
> ?SIGN(a)*CEILING(ABS(a)/10)*10

>
> If the values contain subunits (cents), then your solution would be :
>
procedure round10
> lparameters n
>    return round(abs(n)+4.999,-1)*sign(n)
> endproc

>
> P.S.
> I need to apologize but I'm a poor english speaker. What do you mean by [snip]?
>
> My respects

either this:
http://en.wikipedia.org/wiki/Snipping_Tool
or this:
http://www.thefreedictionary.com/snip
but best:
http://wiki.answers.com/Q/What_is_a_snip

.

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