PHP General - Octal and Decimal Numbers
Interview Question Database For Software Developers
|
|
| Octal and Decimal Numbers | | I am trying to assign a variable the value of 0123,
but it keeps coming up with a different number, what's
the problem? | | By: FYIcenter | If you assign a variable with a value of 0123, PHP
will interpret as an octal number resulting to decimal
value of 83.
All numbers that preceded with a 0 (zero) will be
interpreted as octabl numbers. This is one of the PHP
literal data rules.
For example, the PHP script below will produce: 83 and
123.
<?php
$octal = 0123; // octal number (equivalent to 83
decimal)
$decimal = 123; // decimal number
echo $octal ."\n";
echo $decimal ."\n";
?>
| | ID: 76 | Rank: 1347 | Votes: 0 | Views: 245 | Submitted: 20070227 |
1347 :-) | | Octal and Decimal Numbers | | I am trying to assign a variable the value of 0123,
but it keeps coming up with a different number, what's
the problem?... | | Submitted: 20070227 |
|
Copyright © 2009 FYIcenter.com
All rights in the contents of this Website are reserved by the individual author.
No part of the contents may be reproduced in any form without author's permission.
|
|
|