ID:1456383
 
Not a bug
BYOND Version:503
Operating System:Windows 8 64-bit
Web Browser:Chrome 31.0.1650.63
Applies to:Dream Maker
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
When I compile code with a switch() statement, the numbers 008 and 009 do not compile properly and throws a bad number error.

Numbered Steps to Reproduce Problem:
Create a function that uses 008 or 009 integers in a switch statement.

Code Snippet (if applicable) to Reproduce Problem:
mob/proc
ChangeHair(var/HairNum)
switch(src.Gender)
if("Male")
switch(HairNum)
if(001)
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Male/Head/_001Hair_M/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=001

if("Female")
switch(HairNum)
if(001)
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_001Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=001

if(002)
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_002Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=002

if(003)
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_003Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=003

if(004)
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_004Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=004

if(005)
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_005Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=005

if(006)
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_006Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=006

if(007)
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_007Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=007

if(008)

//The error happens here
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_008Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=008

if(009)

//And here.
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_009Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=009

if(010)
src.overlays-=src.Char_Overlays["Hair"]
var/obj/Characters/Female/Head/_010Hair_F/O=new()
Char_Overlays["Hair"]=O
src.overlays+=Char_Overlays["Hair"]
src.HairNum=010

UpdateOverlays()


Expected Results:
The compiler to compile the switch() statement without throwing a compile time error.

Actual Results:
The compiler throws a bad number error on switch() statements for the values 008 and 009.
Does the problem occur:
Every time? Or how often?
Every time.
In other games?
N/A
In other user accounts?
N/A
On other computers?
Unknown.

When does the problem NOT occur?
It always occurs on this version.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? I do not know if it didn't happen in earlier versions.

Workarounds:
None known.
DarkCampainger resolved issue (Not a bug)
If you put a zero in front of the number, it's interpreted in the octal number system (base-8 instead of base-10 like decimal). In the octal system, only 0-7 are valid digits, so your 008 and 009 are invalid.

It's also worth noting that 010 is equal to 8, and not 10 like you expect.

So you just have to remove those zeros to have it work as you expected. Use spaces if you want them to line up.
In response to DarkCampainger
DarkCampainger wrote:
If you put a zero in front of the number, it's interpreted in the octal number system (base-8 instead of base-10 like decimal). In the octal system, only 0-7 are valid digits, so your 008 and 009 are invalid.

Ah, I see! Good to know, thanks!
In response to DarkCampainger
DarkCampainger wrote:
If you put a zero in front of the number, it's interpreted in the octal number system (base-8 instead of base-10 like decimal).

This is really interesting.