Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert a number to a string

Status
Not open for further replies.
Jul 23, 2010
5
0
0
US
can anyone show me how to convert a number to string in coldfusion?
 
Actually what I really want is For example
x=(23464.4356). I use
<cfset x = numberformat(x, "99999.99")>
I only want the 23464.43, but I keep getting 23464.44
Is there anyway of getting just the first 2 digit after the decimal point.

I couldnot figure out how to do it, so I thought of using converting x to a string first.

Anyone can tell me how to just get the first 2 digit after the decimal point is greatly appreciate it.
 
<CFSET x = 23464.4356 >

<CFSET y = Int(x * 100) * 0.01 >

<CFOUTPUT>
x = #x# <br>
y = #y# <br>
</CFOUTPUT>

:)

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Yes, annoyingly NumberFormat() also rounds the input value. It would be nice if there was a flag to control the behavior .. but there is not. So rolling your own function is the way to go ;-)

----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top