View Single Post
Old 11-29-2008, 03:56 PM   #3 (permalink)
kuigg
The Wanderer
 
kuigg's Avatar
 
Join Date: Nov 2008
Posts: 7
Thanks: 2
kuigg is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
The number 042 is an octal number (base 8) rather than a 'normal' decimal number (base 10). It's the octal 42 which can be explained below:

Octal
Code:
32 16  8  1
-  -   4  2
To work out the decimal value, multiply the header line by the digit line and sum those values. 8*4 + 1*2 which gives 34.

Compare this to decimal numbers
Code:
1000 100 10  1
-    -   4   2
Multiplying the values together again: 10*4 + 1*2 which gives 42.

You can also use hexadecimal (base 16) by preceding the number with 0x. For example, all of the following have an integer value of 123.

PHP Code:
$num 123;  // decimal
$num 0x7B// hexadecimal
$num 0173// octal 
More information can be found on the integers PHP manual page.
thank you very much.
kuigg is offline  
Reply With Quote