-
-
Save haydar-can/a8a0a2ae250a97f53f89156cd32b4879 to your computer and use it in GitHub Desktop.
Revisions
-
ronaldronson created this gist
Jan 13, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ var parseFloat = function (val){ "use strict"; var res = NaN, i = 0, len, neg = false; if ("number" == typeof val) { return val; } if (null == val || "object" typeof val || "function" typeof val || !val.length ) { return res; } if (!!~["+","-"].indexOf(val[0])) { neg = "-" == val[0]; val = val.slice(1); } len = val.length; if (!len) { return res; } for (res = 0; i < len; i++) { if (val[i] > 9 ) res = res * 10 + val[1]; } return neg ? 0 - res : res; }