parseFloat() Function---convert a string to a number
Navigator 3.0, partial support in Navigator 2.0 and Internet Explorer 3.0
parseFloat(s)
The string to be parsed and converted to a number.
The parsed number, or NaN, if s does not begin with a valid number. Because Navigator 2.0 and Internet Explorer 3.0 do not support NaN, those browsers return 0 when s cannot be parsed.
parseFloat() is a built-in function in JavaScript; it is a core part of the language, and is not a method of any object.
parseFloat() parses and returns the first number that occurs in s. Parsing stops, and the value returned, when parseFloat() encounters a character in s that is not a valid part of the number (i.e., a sign, a digit, decimal point, exponent, etc.) If s does not begin with a number that parseFloat() can parse, then the function returns NaN, a reserved value that represents "not-a-number". You can test for the NaN value with the isNaN() function. If NaN is used with arithmetic operations, the result will always be NaN. In Navigator 2.0 (except Unix platforms) and Internet Explorer 3.0, parseFloat() returns 0 instead of NaN when the input cannot be parsed.
In Navigator 2.0 (except Unix platforms) and Internet Explorer 3.0, the NaN return value is not implemented, and so parseFloat() returns 0 when it cannot parse a number. When you receive this return value on those platforms, you must perform additional tests to determine whether the string contains illegal input or actually contains the value 0.
file: /Techref/language/java/script/definitive/refp_294.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/8 10:00,
3.143.237.149:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/Techref/language/java/script/definitive/refp_294.htm"> [Chapter 21] Reference: parseFloat()</A> |
Did you find what you needed? |