View Single Post
Old 05-02-2012, 07:49 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,098
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
As its name implies, parseInt() parses a string value and returns an integer. Syntax:- parseInt(string, radix)
If the radix parameter is omitted, JavaScript assumes the following:
- If the string begins with "0x", the radix is 16 (hexadecimal)
- If the string begins with "0", the radix is 8 (octal). This feature is deprecated
- If the string begins with any other value, the radix is 10 (decimal)

parseFloat() returns the real (decimal or floating point) value of the number parsed from a string value. If the first character in the string is a number, it parses the string until it reaches the end of the number, and returns the number as a number, not as a string.

You should also take a look at the Number() function.

Note that as always Javascript is case-sensitive and parseint will return an error.

"We have to remember that horses are only human ...." - Racing commentator
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote