Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Luis Maria Guayan
  Where is Luis Maria Guayan?
 Yerba Buena
 Argentina
 Luis Maria Guayan
 To: joe Degorio
  Where is joe Degorio?
 Tacloban City
 Philippines
 joe Degorio
 Tags
Subject: RE: Rounding
Thread ID: 289085 Message ID: 289131 # Views: 37 # Ratings: 5
Version: Visual FoxPro 9 Category: Forms
Date: Tuesday, December 28, 2010 3:33:33 PM         
   


> Hi,
> Advance Happy New Year to everyone! And just want to ask how can I round these numbers to the following (if possible)...
>
> 195.34 -> 195.35
> 85.22 -> 85.25
> 900.72 -> 900.75
>
> thanks and regards,
> joe

With these functions you can round X cents up or down.

lnNro = 195.34

? RoundPlusXCent(lnNro, 5)
? RoundMinusXCent(lnNro, 5)
?
? RoundPlusXCent(lnNro, 25)
? RoundMinusXCent(lnNro, 25)
?
? RoundPlusXCent(lnNro, 50)
? RoundMinusXCent(lnNro, 50)

FUNCTION RoundMinusXCent(tnVal, tnDec)
  RETURN Floor(tnVal * 100/tnDec) / (100/tnDec)
ENDFUNC

FUNCTION RoundPlusXCent(tnVal, tnDec)
  RETURN CEILING(tnVal * 100/tnDec) / (100/tnDec)
ENDFUNC


Luis María Guayán
Tucumán, Argentina
________________________________
SysOp de www.PortalFox.com

ENTIRE THREAD

Rounding Posted by joe Degorio @ 12/28/2010 9:28:25 AM
RE: Rounding Posted by Ony Too @ 12/28/2010 9:47:05 AM
RE: Rounding Posted by Samir H. @ 12/28/2010 10:32:33 AM
RE: Rounding Posted by Luis Maria Guayan @ 12/28/2010 3:33:33 PM