Re: sizeof(int)
| From: | Hugh Bothwell | Date: | Sat, 25 Aug 2001 13:25:26 +0000 |
| Subject: | Re: sizeof(int) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64431@lists.php.net to get a copy of this message | ||
"Saurabh Kapoor" <saurabh.kb@btinternet.com> wrote in message
news:001901c12d63$b1b62100$9e2823d9@killer666...
> I am a C programmer, looking to migrate some code to PHP (Unusual, but my
> colleagues request it).
>
> Can someone tell me the size (in bytes) of the type int in PHP.
>
> I need a 16 bit (2 byte) storage unit (I use a lot of bitwise operations)
Try this:
<?php
$val = 2; $last = 1; $pow = 1;
echo "<pre>\n(0) 1\n(1) 2";
while ($val > $last) {
$last = $val;
$val = $val << 1;
$pow++;
echo "\n($pow) $val";
}
echo "</pre>";
?>
Running PHP 4.0.6 on WinMe, I get 32 bits.