On 2008.05.03, William Scott Jordan <[EMAIL PROTECTED]> wrote: > Yuck. Okay, so is there any practical work-around for getting X.XX5 to > consistently round up? I suppose I could do something like add > 0.0000001 to any number that I'm rounding, but that seems pretty sloppy. > Is there a best practice for dealing with this?
Best practice? Use integers, format as decimal value as needed. This is often why you'll see financial applications store money values in cents or hundredths of a cent, i.e., a dollar is stored as either "100" (100 pennies) or "10000" ... if they deal in quantities that include fractional cents. Only at the point where the data leaves the system, either to a UI or to another system, do they format it with the decimal point in place. This approach generally eliminates all floating-point precision and rounding issues and can even result in a performance increase in compute-heavy applications where the machine's CPU handles integer math faster than floating-point math. -- Dossy Shiobara | [EMAIL PROTECTED] | http://dossy.org/ Panoptic Computer Network | http://panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70) -- AOLserver - http://www.aolserver.com/ To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.