How to left shift binary bits using php

20 views
Skip to first unread message

anjith

unread,
Sep 4, 2010, 8:02:46 AM9/4/10
to Professional PHP Developers
Hi,
I tired to rotate a group of binary bits using << operator in php but
as these are binary bits they are converted to corresponding decimal
value so result is not what i expected.

I gave $x=011110101011111, I tired to left rotate these bits by
converting these bits string also but no use.

PHP is treating these as binary bits not as string unfortunately i
willl get data from database as bits only. I tired to convert these
bits into string but before converting only it is taking corresponding
decimal value.

Felipe Nascimento de Moura

unread,
Sep 4, 2010, 10:58:59 AM9/4/10
to professi...@googlegroups.com
the operand << and >> can shift bits

--
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.

For information or project assistance please visit :
http://www.360psg.com

You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professi...@googlegroups.com
To unsubscribe from this group, send email to Professional-P...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Professional-PHP



--

Felipe N. de Moura

Web Development

http://felipenascimento.org
http://twitter.com/felipenmoura
LinkedIn: http://goo.gl/qGmq
---------------------------------
LinuxUser #508332
Making the web a better place to live

Jolly

unread,
Sep 4, 2010, 11:05:49 AM9/4/10
to Professional PHP Developers
<?php
print 2 << 1;


should print 4;

Subir Jolly

unread,
Sep 4, 2010, 11:06:31 AM9/4/10
to professi...@googlegroups.com
my bad.. i did not read your question.

Jolly

unread,
Sep 4, 2010, 11:08:13 AM9/4/10
to Professional PHP Developers
Felipe's link is perfect..


On Sep 4, 8:02 am, anjith <anjithkumar.garap...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages