15.1.2.3 parseFloat(string)

2010-07-03

number parseFloat(string:string)

- Does not accept a radix parameter so parsing is much simpler
- Skips leading whitespace
- Unlike parseInt it does not skip (other) unknown leading characters
- Will stop parsing at the first unknown character it encounters
- Applies or enforces the StrDecimalLiteral production to that prefix

Code: (Meta Ecma)
function parseFloat(string){
var inputString = ToString(string);
var trimmedString = inputString.trim();
// this is where it gets a little fuzzy for meta language
// if no trimmedString nor any substring of trimmedString satisfies the syntax of StrDecimalLiteral (see 9.3.1) return NaN
// let numberString be the longest prefix of trimmedStrings that satisfies StrDecimalLiteral
// return the MV of numberString
}

Step 3 and 4 of the algorithm in the specification could probably be rewritten to this:
3. let prefix be the longest prefix of trimmedString that satisfies the syntax of StrDecimalLiteral
4. if the length of prefix is 0 return NaN
5. return the MV of prefix

Ohwell.