please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next

 


parseFloat() Function

Name

parseFloat() Function---convert a string to a number

Availability

Navigator 3.0, partial support in Navigator 2.0 and Internet Explorer 3.0

Synopsis

parseFloat(s)

Arguments

s

The string to be parsed and converted to a number.

Returns

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.

Description

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.

Bugs

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.

See Also

"isNaN()", "parseInt()"

[Chapter 9] 9.2 Explicit Data Type Conversions


Previous Home Next
parent Book Index parseInt()


HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/JAVA/script/definitive/refp_294.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/19 20:31,
TOP NEW HELP FIND: 
18.189.184.250:LOG IN

 ©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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/techref/language/JAVA/script/definitive/refp_294.htm"> [Chapter 21] Reference: parseFloat()</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .