Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001092

Re: [PHP] Weird results from Left Shift From: Rasmus Lerdorf (rasmus <email protected>)
Date: 09/19/01

> <?php
> $num = 8;
> $num = decbin($num);
> echo "Number is $num<BR>";
> $num = $num << 1;
> echo "Shifted Number is $num";
> ?>

But you are using it wrong. decbin() returns a string with a binary
pattern in it. You can't shift a string. You shift numbers. If you
already know the decimal value of the number you want to shift you don't
have to do anything. I suggested bindec() because I thought you wanted to
provide a binary representation of the number for some reason.

-Rasmus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>