{"id":2180,"date":"2022-08-30T15:22:43","date_gmt":"2022-08-30T15:22:43","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/04\/how-fast-is-parsefloat-vs-float-ints-in-javascript-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:22:43","modified_gmt":"2022-08-30T15:22:43","slug":"how-fast-is-parsefloat-vs-float-ints-in-javascript-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/how-fast-is-parsefloat-vs-float-ints-in-javascript-collection-of-common-programming-errors\/","title":{"rendered":"How fast is parseFloat Vs. float ints in JavaScript?-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m getting a huge dataset from a client&#8217;s internal API. It&#8217;ll contain a bunch of numerical data of prices such as: $31.23. He gives them to me as <code>{\"spend\":\"21.23\"}<\/code> which is fine, but I was concerned that after 1000+ items and running <code>parseFloat()<\/code> on all of those values (on top of graphing them) might be resource heavy on the client&#8217;s browser.<\/p>\n<p>Has anyone done this?<\/p>\n<p>==Update==<\/p>\n<p>I&#8217;m sorry. My question was too vague. My concern was that it&#8217;s a string and i&#8217;m parsing it. My issue was is parseFloat faster than just an int. I.e. is appending <code>parseFloat(\"12.12\")<\/code> to a div faster than simply just appending <code>12.12<\/code> and if so, how much faster.<\/p>\n<ol>\n<li>\n<p>On my work machine (Mac OS X, Intel 2 GHz Core i7), I saw the following results on jsperf.com:<\/p>\n<pre><code>Browser    | parseFloat calls per second\n----------------------------------------\nChrome 12  | 5.3 million\nFirefox 6  | 21.7 million\nIE 8       | 666.9 thousand<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-04 02:51:51. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m getting a huge dataset from a client&#8217;s internal API. It&#8217;ll contain a bunch of numerical data of prices such as: $31.23. He gives them to me as {&#8220;spend&#8221;:&#8221;21.23&#8243;} which is fine, but I was concerned that after 1000+ items and running parseFloat() on all of those values (on top of graphing them) might be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2180","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2180"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2180\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}