This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

parseFloat

Summary

Converts a string to a floating-point number.

Syntax

parseFloat( numString )

Examples

parseFloat("123.45")  // returns 123.45
parseFloat("abc")  // returns NaN
parseFloat("1.2abc")  // returns 1.2

Remarks

The required numString argument is a string that contains a floating-point number.

The parseFloat function returns a numerical value equal to the number contained in numString. If no prefix of numString can be successfully parsed into a floating-point number, NaN (not a number) is returned.

You can test for NaN using the isNaN function.

See also

Other articles

Attributions

  • Microsoft Developer Network: Article