Because it is money I need to int/trunc/floor the value. -----Original Message----- From: Barney Boisvert [mailto:[EMAIL PROTECTED] Sent: Monday, December 12, 2005 5:32 PM To: CF-Talk Subject: Re: Is this a bug in CFMX?
Don't use int(), use round(). int() truncates, and is equivalent to the floor() (the inverse of ceiling()) function found in most languages. round(), on the other hand, follows normal rounding rules (0-4 goes down, 5-9 goes up). cheers, barneyb On 12/12/05, Shawn McKee <[EMAIL PROTECTED]> wrote: > So if I need to accurately convert a floating point number with X digits in the decimal portion to one with Y (Y < X) digits what do I do? For instance 10.3456 to 10.34. > > I have to do currency conversion prior to hitting a credit card. The credit card is limited to two decimal points but the conversion can end up with many more. I wrote this: > > numOut = (int(numIn * 100))/100 > > and thought all would be well. However it is regularly off by .01 which is obviously a problem when dealing with money. > > Shawn McKee > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 100 invites. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:226885 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54