Welcome Guest, Not a member yet? Register   Sign In
Why $var = 012 / 4 = 2.5?
#1

[eluser]greedyman[/eluser]
As title, anyone know why? I searched on the internet but I don't have an answer yet.
#2

[eluser]sv3tli0[/eluser]
when you have 0 infront its Octal number not Decimal ...
012(octal) = 10(decimal) / 4 = 2.5 Smile

Octal numbers: 0-7
Decimal: 0-9

If you cast it to int it will show int number...

Code:
var_dump( (int) 012 );

int 10
#3

[eluser]greedyman[/eluser]
[quote author="sv3tli0" date="1374735500"]when you have 0 infront its Octal number not Decimal ...
012(octal) = 10(decimal) / 4 = 2.5 Smile

Octal numbers: 0-7
Decimal: 0-9

If you cast it to int it will show int number...

Code:
var_dump( (int) 012 );

int 10
[/quote]

Thanks for helping me! I see your answer.




Theme © iAndrew 2016 - Forum software by © MyBB