views:

149

answers:

5

What doesn't this work:

(int)08 == (int)09==0

But this and this does?

(int)07==7 
(int)06==6
+14  A: 

08 is in octal base (because it starts with a 0), hence it is invalid. See the documentation.

Jerome
+11  A: 

because 08 and 09 are not valid octal numbers. see warning in docs.

SilentGhost
+1  A: 

You're type casting an invalid number in octal base.

Sarfraz
A: 

To use hexadecimal notation precede the number with 0x.

Therefore,

 $num = (int)0x9
 $num == 9
CodeJoust
A: 
// Syntax error
//(int)08 == (int)09==0

// This works
(int)08==0;
(int)09==0;

// This also works
(int)08 == ((int)09==0);
Peter Lindqvist