Originated from
QueryCAT

How can I convert float to String in javascript ...

How can I convert float to String in javascript ?? Need ASAP


Share Send to a friend Watch Report
 
 

2 Posted Answers
Order by

 
17 helpful answers

Javascript will convert types automatically if you just use them in a context where that needs to happen.  For example, you can just add an empty string to your float and the result will be a string:

var x = 3.14952;
var y = x + '';
window.alert( typeof x ); // number
window.alert( typeof y ); // string

You can also do explicit casting, but it's usually not necessary. 

Posted 2008-04-14T23:00:13Z
Helpful?(2)
Rated as Best Answer
 
5 helpful answers

robertc is very right. In case you may also be looking for String-to-float: that is not as automatic. You can use the globally defined function parseFloat(f). so parseFloat("0003.1415") would result in 3.1415. ParseFloat (and also parseInt) will skip any leading non-number characters btw, such as US$ e.g.

Posted 2008-04-22T01:17:13Z
blonkm was invited by Yedda to answer this question.

Helpful?(2)
Rated as Best Answer

Sign in to participate

Got an answer for MBW1185? Would you like to comment on the posted answers, or vote for the one which you think is the best?

Sign up for a free account, or sign in (if you're already a member).

Explore Related Questions

Other people asked questions on similar topics, check out the answers they received:


Q:

How do I convert a javascript byte array to a java ...

How do I convert a javascript byte array to a java byte array?? Basically I am calling a javascript method that returns me a ...
Submitted by Jumbu   1 year ago.
  • viewed 2786 times


Q:

How much "give" will a floating floor be expected ...

How much "give" will a floating floor be expected to have? I would like to install an engineered click over a concrete slab. But ...
Submitted by TJ Moon   1 year ago.
  • viewed 267 times
Last answer posted 1 year ago by Skitch


Q:

What are the risks of floating exchange rate for ...

what are the risks of floating exchange rate for companies involved in international business
Submitted by monty   2 years ago.
  • viewed 391 times
Last answer posted 7 days ago by primerealadstate



» More...

Explore Related Posts in Forums

How do I convert a float to an int in Javascript?

I'd like to convert a float to an int in Javascript. Actually, I'd like to know how to do BOTH to a string and parsing. I'd like to convert a float to an int in Javascript. Actually, I'd like to know how to do BOTH of the standard convertions...

convert string from money format to float in js

I'd like to convert a money formatted string into a float in javascript. ex: '$1,000.20' convert to a float 1000.20 'USD 1,000.20' convert to a float 1000.20 I'm also interested to know how Use JavaScript substring() Method to strip off letters and then parse using parseFloat parseFloat

to check float values in javascript, any fun??

Tell me Guys , If there is any Fun to check float numbers in javascript ?? Tell me d solution parseFloat will convert a string into a floating point number. Tell me Guys , If there is any Fun to check float numbers in javascript ?? Tell me d solution Thanks Amit
» More...
Powered by
Feed - Subscribe to changes to this Q&A Blog
ADVERTISEMENT
ADVERTISEMENT
AOL Autos Q&A is powered by Yedda an AOL Company
Copyright © 2006-2010, Yedda Inc. and respective copyright owners