> $num = 8;
> $num = decbin($num);
> echo "Number is $num";
> $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 n
age -
From: "Rasmus Lerdorf" <[EMAIL PROTECTED]>
To: "Sheridan Saint-Michel" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, September 19, 2001 3:51 PM
Subject: Re: [PHP] Weird results from Left Shift
> > Okay, from the manual I have
>
> Okay, from the manual I have
> $a << $b - Shift the bits of $a $b steps to the left
>
> When I run the code
>
> $num = "0001000";
> echo "Number is $num";
> $num = $num << 1;
> echo "Shifted Number is $num";
> ?>
>
> I get the output
>
> Number is 0001000
> Shifted Number is 2000
>
> What am I
> Okay, from the manual I have
> $a << $b - Shift the bits of $a $b steps to the left
>
> When I run the code
>
> $num = "0001000";
> echo "Number is $num";
> $num = $num << 1;
> echo "Shifted Number is $num";
> ?>
>
> I get the output
>
> Number is 0001000
> Shifted Number is 2000
>
> What
4 matches
Mail list logo