Re: Re: Binary math
| From: | Mark | Date: | Fri, 11 Jun 2004 12:00:57 +0000 |
| Subject: | Re: Re: Binary math | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-188097@lists.php.net to get a copy of this message | ||
--- Knightking <Knightking@smempire.org> wrote:
> On Thu, 10 Jun 2004 20:08:08 -0700, Justin Patrin
> <papercrane@reversefold.com> wrote:
>
> > Mark wrote:
> >
> >> [snip]
> >
> > I'm not sure what's wrong with the code you have, but for the
> 4-digit
> > one you have:
> >
> > $packed = 4-bit var with ABCD encoded in it
> >
> > $a = $packed & 1;
> > $b = $packed & 2;
> > $c = $packed & 4;
> > $d = $packed & 8;
> >
> Just as a side tip, I highly recommend using hexadecimal for
> bitwise
> functions where possible, i.e.:
> $a = $packed & 0x1;
> $b = $packed & 0x2;
> $c = $packed & 0x4;
> $d = $packed & 0x8;
> $e = $packed & 0x10;
> $f = $packed & 0x20;
> $g = $packed & 0x40;
> $h = $packed & 0x80;
> $i = $packed & 0x100;
Thanks guys. I never really used bitwise operators, but I knew they'd
come in handy one day. Thanks for the tips. Now I just need to get
this monster working.
Mark
>
> Using M2, Opera's revolutionary e-mail client:
> http://www.opera.com/m2/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
=====
Mark Weinstock
mark_weinstock@yahoo.com
***************************************
You can't demand something as a "right" unless you are willing to fight to death to
defend everyone else's right to the same thing.
***************************************
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/