javascript parseInt("08") return the value 0

Bug #887567 reported by cubrad
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
firefox (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

the javascript function parseInt returns 0 when used with the string "08" or "09" :

parseInt("08") returns the value 0
parseInt("09") returns the value 0
but
parseInt("01") returns the value 1
parseInt("02") returns the value 2
and so on until "07"

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: firefox 7.0.1+build1+nobinonly-0ubuntu0.11.04.1
ProcVersionSignature: Ubuntu 2.6.38-8.42-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic x86_64
NonfreeKernelModules: nvidia
AddonCompatCheckDisabled: False
AlsaVersion: Advanced Linux Sound Architecture Driver Version 1.0.23.
Architecture: amd64
AudioDevicesInUse:
 USER PID ACCESS COMMAND
 /dev/snd/controlC0: michel 2119 F.... pulseaudio
BuildID: 20110928224508
Card0.Amixer.info:
 Card hw:0 'NVidia'/'HDA NVidia at 0xfe020000 irq 21'
   Mixer name : 'Nvidia MCP77/78 HDMI'
   Components : 'HDA:10ec0888,10438321,00100101 HDA:10de0002,10de0101,00100000'
   Controls : 44
   Simple ctrls : 23
Channel: release
CurrentDmesg: Error: command ['sh', '-c', 'dmesg | comm -13 --nocheck-order /var/log/dmesg -'] failed with exit code 1: comm: /var/log/dmesg: Permission denied
Date: Tue Nov 8 14:17:38 2011
ForcedLayersAccel: False
IncompatibleExtensions: JavaScript Debugger - ID={f13b157f-b174-47e7-a34d-4815ddfdfeb8}, Version=0.9.88.2, minVersion=1.9.1, maxVersion=2.0.*, Location=app-profile, Type=extension, Active=Yes
IpRoute:
 192.168.7.0/24 dev eth1 proto kernel scope link src 192.168.7.1 metric 1
 169.254.0.0/16 dev eth1 scope link metric 1000
 default via 192.168.7.126 dev eth1 proto static
Plugins:
 Shockwave Flash - Lib=libflashplayer.so, Location=/usr/lib/mozilla/plugins
 QuickTime Plug-in 7.6.6 - Lib=libtotem-narrowspace-plugin.so, Location=/usr/lib/mozilla/plugins
 DivX® Web Player - Lib=libtotem-mully-plugin.so, Location=/usr/lib/mozilla/plugins
 Windows Media Player Plug-in 10 (compatible; Totem) - Lib=libtotem-gmp-plugin.so, Location=/usr/lib/mozilla/plugins
 VLC Multimedia Plugin (compatible Totem 2.32.0) - Lib=libtotem-cone-plugin.so, Location=/usr/lib/mozilla/plugins
ProcEnviron:
 LANGUAGE=fr_FR:en
 LANG=fr_FR.UTF-8
 SHELL=/bin/bash
Profiles: Profile0 (Default) - LastVersion=7.0.1/20110928224508 (Running)
RunningIncompatibleAddons: True
SourcePackage: firefox
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 06/11/2010
dmi.bios.vendor: Phoenix Technologies, LTD
dmi.bios.version: ASUS M3N-HD/HDMI ACPI BIOS Revision 2703
dmi.board.name: M3N-HD/HDMI
dmi.board.vendor: ASUSTeK Computer INC.
dmi.board.version: 1.XX
dmi.chassis.asset.tag: 123456789000
dmi.chassis.type: 3
dmi.chassis.vendor: Chassis Manufacture
dmi.chassis.version: Chassis Version
dmi.modalias: dmi:bvnPhoenixTechnologies,LTD:bvrASUSM3N-HD/HDMIACPIBIOSRevision2703:bd06/11/2010:svnSystemmanufacturer:pnSystemProductName:pvrSystemVersion:rvnASUSTeKComputerINC.:rnM3N-HD/HDMI:rvr1.XX:cvnChassisManufacture:ct3:cvrChassisVersion:
dmi.product.name: System Product Name
dmi.product.version: System Version
dmi.sys.vendor: System manufacturer

Revision history for this message
cubrad (michel-lopez) wrote :
Revision history for this message
Chris Coulson (chrisccoulson) wrote :

That's expected. Numbers with a leading zero are considered octal numbers in Javascript, and "8" and "9" are not valid octal digits (which is why everything up to "07" works).

Changed in firefox (Ubuntu):
status: New → Invalid
Revision history for this message
cubrad (michel-lopez) wrote : Re: [Bug 887567] Re: javascript parseInt("08") return the value 0

Le mardi 08 novembre 2011 à 13:40 +0000, Chris Coulson a écrit :
> That's expected. Numbers with a leading zero are considered octal
> numbers in Javascript, and "8" and "9" are not valid octal digits (which
> is why everything up to "07" works).
>

lol, I spend a thousand hours looking why my script was bugging.

thanks for explaining this.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.