Re: [PHP] Fun with Binary Numbers

2002-08-28 Thread Stas Maximov
;[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 28, 2002 3:11 PM Subject: [PHP] Fun with Binary Numbers > Here's a question, > > Say I have a binary number like this > > 1101 0100 0110 0110 > > And I want to pull out of the binary number th

Re: [PHP] Fun with Binary Numbers

2002-08-28 Thread Rasmus Lerdorf
Well, to begin with applying the mask to 1101 0100 0110 0110 is going to give you 110 not 110. But you can shift the result to the right 4 if that is the result you want. There is no algorithm to speak of here, just apply the mask. Like this: $num = "1101010001100110"; $

[PHP] Fun with Binary Numbers

2002-08-28 Thread David Buerer
Here's a question, Say I have a binary number like this 1101 0100 0110 0110 And I want to pull out of the binary number the third quartet (is that the right word) I want to know how to apply the mask to the number above so that the result would be