Tag: parseInt

parseInt Bug in Firefox, IE6 and IE7 for values “08” and “09”

by on Mar.18, 2008, under Software Development

Quick Entry:

There is a bug in shipping versions of Internet Explorer and Firefox wherein if you attempt to use parseInt on a number with leading zeros, the value returned will be incorrect for “08” and for “09” due to the Javascript interpreter thinking these are, in fact, Octal numbers (and there being no “Octal” value greater than 7, the value returned is “0”).

Try it.  Copy/Paste the following Javascript into your browser’s url:


Anyway, a somewhat esoteric bug perhaps but it did cause an infinite loop today when I was attempting to scan over a date range where the dates were stored with leading zeroes.

The fix?

USE parseFloat() instead.

Leave a Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!


A few highly recommended websites...

  • A List Apart
  • Dive into HTML5
  • Javascript: The Good Parts
  • QuirksMode.org