Octals

Hi,

I was reading the java certification book and it mentions that octals can have up to 21 digits not including the zero. However in eclipse, when I try to assign to a long, I can only get to 037777777777 (11 digits) before the compiler tells me it's out of range.

long octal = 037777777777;

System.out.println("octal max = " + octal);

Also, by my calculations wouldn't it be 22 digits i.e.

01777777777777777777777 = 0xFFFFFFFF

I feel like I'm missing something obvious here.

Thanks,

[594 byte] By [Raphael.Blancharda] at [2007-11-27 8:16:58]
# 1

> I was reading the java certification book and it

> mentions that octals can have up to 21 digits not

> including the zero. However in eclipse, when I try

> to assign to a long, I can only get to 037777777777

> (11 digits) before the compiler tells me it's out of

> range.

that's because your literal is an int, not a long.

Tried 03777777777777777L?

CeciNEstPasUnProgrammeura at 2007-7-12 20:02:04 > top of Java-index,Java Essentials,Java Programming...