Re: Weird results from Left Shift

From: Date: Wed, 19 Sep 2001 21:35:52 +0000
Subject: Re: Weird results from Left Shift
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-67902@lists.php.net to get a copy of this message
I already tried that before posting the question. <?php $num = 8; $num = decbin($num); echo "Number is $num<BR>"; $num = $num << 1; echo "Shifted Number is $num"; ?> Gives me the output: Number is 1000 Shifted Number is 2000 Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com ----- Original Message ----- From: "Rasmus Lerdorf" <rasmus@php.net> To: "Sheridan Saint-Michel" <webmaster@foxjet.com> Cc: <php-general@lists.php.net> Sent: Wednesday, September 19, 2001 3:51 PM Subject: Re: [PHP] Weird results from Left Shift > > Okay, from the manual I have > > $a << $b - Shift the bits of $a $b steps to the left > > > > When I run the code > > > > <?php > > $num = "0001000"; > > echo "Number is $num<BR>"; > > $num = $num << 1; > > echo "Shifted Number is $num"; > > ?> > > > > I get the output > > > > Number is 0001000 > > Shifted Number is 2000 > > > > What am I missing?!? > > Use: $num = bindec("0001000"); > > -Rasmus > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#67902) next »