If not for the scientific notation, I could just display the number as returned by the query. Is the an SQL function that will convert the number to it's true form rather then the scientific notation? Then I won't have to worry about CF's numberformat.
Russ -----Original Message----- From: Jim Davis [mailto:[EMAIL PROTECTED] Sent: 12 February 2006 18:00 To: CF-Talk Subject: RE: Decimal places > -----Original Message----- > From: Snake [mailto:[EMAIL PROTECTED] > Sent: Sunday, February 12, 2006 6:20 AM > To: CF-Talk > Subject: RE: Decimal places > > Barney, > > I'm not sure why your not sure, I think I explained it pretty well. > > > My problem is that I need to display the original number in it's > > original format unchanged. > > So if the number is 345 > I want to display 345 > If the number is 2367457234572345723 > I want to display 2367457234572345723 > If the number is 34.89 > I want to display 34.89 > > Whether or not 1.078E+07 is called an equation or a notation is > totally irrelevant, this is how long numbers are stored in the > database, if you Actually it's probably not how their stored in the DB. The DB would probably store them directly as a bit-defined float. > output the column, you will get is displayed as 1.078E+07, which is no > good, Although it could be the database doing this it's also likely to be the driver you've chosen to use (JDBC or ODBC for example) - they do more data conversion that you'd think sometimes. > so you have to use Numberformat() to display the real number. This > then causes the problem I have detailed below, you cannot display the > original number in it's original format, you either have to force > decimal points or exclude them. Understanding the scientific notation is pretty key here - that's the only reason that people are stressing it. Scientific notation is the number - it's not "converted" or "run" or anything like that - it IS the number. So, for example, you can do this: <cfset Num = (2.5E-2) + 0> <cfoutput>#Num#</cfoutput> <cfset Num = (1.078E+07) + 0> <cfoutput>#Num#</cfoutput> <cfset Num = (1.23E+11) + 0> <cfoutput>#Num#</cfoutput> Will result in this: 0.025 10780000 123000000000 In these cases the output will NOT be in Scientific notation. CF took one number and added it another then shown you the result in the number format it likes for those numbers - which is not scientific notation. One problem is that CF itself resorts to scientific notation for some numbers - especially very small ones. The following code, for example: <cfset Num = (1.0E-6) + 0> <cfoutput>#Num#</cfoutput> <cfset Num = (0.000001) + 0> <cfoutput>#Num#</cfoutput> Results in: 1E-006 1E-006 CF itself automatically converted the small number to scientific notation for display. For larger numbers it threshold is higher - but it still converts eventually. For example "9999999999999" will convert to "1E+013" but drop one "9" and it won't. This is a real problem - since you never really know when CF will decide that scientific notation is "better". It may be that for your range of numbers it doesn't matter and just adding them to zero would work a treat. You can do something like this: #NumberFormat(Num, "999999999999999999999999999.999999999999999999999")# But as you've seen it'll just give you lots of extra zeros at the end. Adding a zero to the result is no good since CF will just convert some of the results to scientific notation anyway. So you need some sort of "Significant Digit" function that will eliminate unneeded places either before the format or after. To do it before the conversion you need to understand scientific notation - you can build the proper NumberFormat() mask from the notation itself. If you're not comfortable with Scientific notation in the first place then this isn't going to be pleasant. Perhaps easier would be to just to loop down the string from the end and eliminate all the zeros until you get to a non-zero digit - I think that will give you what you want. Jim Davis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:232068 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

