If you do a NumberFormat of cents you get 994.999999999 #NumberFormat(cents), '999.99999999999')#
On 8/13/07, Steve Onnis <[EMAIL PROTECTED]> wrote: > > > Its from a shopping cart form > > Basically what I wanted to do was stop people sending decimal values more > than 2 points. The examples of the implementation I was sent from the > provider showed that they were just removing the decimal point from the > number value and sending that as the cents value. > > Problem is if for some reason the person implementing the credit card > processing passed in 9.995 or something. Then instead of billing the card > 9.99 they would be billed 99.95. > > So I figured I would move the point rather than remove it and make it a > whole number which is why I was doing this. > > I have changed it from FIX() to ROUND() anyway > > Steve > > -----Original Message----- > From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On > Behalf > Of Haikal Saadh > Sent: Monday, 13 August 2007 12:19 PM > To: cfaussie@googlegroups.com > Subject: [cfaussie] Re: Strange FIX() behaviour > > > I remember a thread from here a while back discussing the various > idiosyncrasies of floating point arithmetic, and that you should be really > storing money in cent amounts. > > I've got no first hand experience in this, but have a flip thru the > archives. > > David Harris wrote: > > Something odd is happening there > > > > If you do this: > > > > <cfset cents = 995 > > > <cfoutput> > > #FIX(cents)# > > </cfoutput> > > > > you get the expected result. eg: 995 > > > > The only thing that springs to mind is that maybe: > > > > 9.95 * 100 = 994.99999999 ? > > > > not sure how to prove this theory tho... > > > > > > > > Steve Onnis wrote: > > > >> Has anyone come across this before? > >> > >> <cfset dollar = 9.95 /> > >> <cfset cents = dollar * 100 /> > >> <cfoutput> > >> #FIX(cents)# > >> </cfoutput> > >> > >> outputs 994 > >> > >> I could maybe understand this is i had more decimal places but it is > >> a plain > >> 2 point decimal value. > >> > >> Any ideas? > >> > >> > >> > >> > >> <http://www.inevative.com.au/images/email-stationary/inevativeLogo_sm > >> all.jpg > >> > >> Steve Onnis > >> > >> > >> Director / Head Developer > >> > >> > >> <http://www.inevative.com.au/images/email-stationary/email.jpg> > >> [EMAIL PROTECTED] > >> > >> <http://www.inevative.com.au/images/email-stationary/phone.jpg> +61 > >> 3 9001 > >> 2258 > >> > >> <http://www.inevative.com.au/images/email-stationary/mobile.jpg> > >> 0401 667 > >> 996 > >> > >> <http://www.inevative.com.au/images/email-stationary/web.jpg> > >> www.inevative.com.au > >> > >> <http://www.novahost.com.au> <http://www.threesquares.com.au> > >> <http://www.smsonline.com.au> > >> > > > > > > > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to cfaussie@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en -~----------~----~----~----~------~----~------~--~---