Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Round() problem
Message
From
26/09/2002 15:25:22
 
 
To
26/09/2002 14:52:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00704895
Message ID:
00704915
Views:
16
>I have a rounding problem...
>
>sgft_val = 2932.0047
>Round(sgft_val, 2) produces 2932.00.
>I need it to round up and = 2932.01.
>
>Any suggestions?

Don't use ROUND() alone if you don't want the standard ROUND() behavior; the algorithm rounds up where the next lower fractional portion is .5 or greater; IOW 2932.0047 rounded to 2 decimals will yield 2932.00, while 2932.0051 rounded to 2 decimal places will yield 2932.01

If you -always- want to round up for 2 decimal places, try the following instead:
ROUND(CEIL(nNumberToRoundUp * 100) / 100, 2)
The ROUND() is present only to trim the trailing decimal places; it can be omitted.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform