Quick Search

Converting Strings to Numbers

February 27th, 2010 by admin
Leave a reply »

 

 

How it works:
The argument of parseFloat must be a string or a string expression. The result of parseFloat is the number whose decimal representation was contained in that string (or the number found in the beginning of the string). If the string argument cannot be parsed as a decimal number, the results will be different in different browsers (either 0 or NaN).

Examples (comments in each line give the conversion results):

parseFloat('1.45kg')  // 1.45
parseFloat('77.3')    // 77.3
parseFloat('077.3')   // 77.3
parseFloat('0x77.3')  // 0
parseFloat('.3')      // 0.3
parseFloat('0.1e6')   // 100000

parseInt syntax:   parseInt( 'string' [, base] )

Posted in Javascript

You can follow any responses to this entry through the RSS 2.0 Feed. You can leave a response , or trackback from your own site.

6 commentsAdd your comment
  1. Interesting , how would I make use of this?

  2. Well I found this on Digg, and I like it so I dugg it!

  3. I agree with the author that we need to share the knowledge we gain!. . . . . .

  4. Hi I found your site by mistake when i was searching yahoo for this acne issue, I must say your site is really helpful I also love the design, its amazing!. I don’t have the time at the moment to fully read your site but I have bookmarked it and also add your RSS feeds. I will be back in a day or two. thanks for a great site.

  5. Thanks for taking the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you gain expertise, would you mind updating your blog with more information? It is extremely helpful for me.

  6. I like the layout of your blog and Im going to do the same for mine. Do you have any tips? Please PM ME.

 

Leave a Reply

SEO Company India

search engine marketing company India that offers affordable seo services