One correction. Use GetToken() instead of CF's list functions, otherwise it blows up on a whole number. GetToken() doesn't care if there's a second list element.
<cfset m = GetToken(n, 1, ".") & "." & Left(GetToken(n, 2, "."), 2)> If I knew something about the numbers being manipulated, I might use a formula like this (move the decimal two places to the right, truncate, then move it back): <cfset m = Int(n * 100) / 100> But because of the way most computers represent base-10 floating point numbers in their native binary format, this will in some instances cause a rounding error at the last decimal point. For instance, 10.7894 --> 10.78 but 88954312.59999999 --> 88954312.60 Jim ----- Original Message ----- From: "Dave Carabetta" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Wednesday, February 20, 2002 9:29 PM Subject: Re: Not Rounding Decimals > > We have some numbers to display that have 5 decimal places in the Database > > but we only want to display two of the decimal places but without rounding > > the up or down, in other words 10.69751 needs to display as 10.69. Using > > Number( or LSNumber( and masks rounds the number up or down. > > > > Anyone got any ideas on this? > > > > Man, this is an ugly way to do it, but the only way off the top of my head. > Cut and paste this one to see the output: > > <cfset number = 10.298765> > <cfset wholenumber = ListFirst(number, ".")> > <cfset decimal = Left(ListGetAt(number, 2, "."), 2)> > <cfset newnumber = wholenumber & "." & decimal> > > <cfoutput>#newnumber#</cfoutput> > > Just a thought. I tried things like ToString() thinking that would help, but > CF still rounds it. I'd be curious to see other solutions, if any, myself. > > Regards, > Dave. ______________________________________________________________________ Why Share? Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation � $99/Month � Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

