[PHP] Re: Bitwise operator question

2003-03-03 Thread Philip Hallstrom
Here's how I think about it...

CREATE_RECORDS = 1 in decimal and 0001 in binary.
ALTER_RECORDS = 4 in decimal and 0101 in binary.

that line returns a binary string where *any* of the bits are 1, so line
them up:

   0001
|  0101
=  0101

which is 5.

On Mon, 3 Mar 2003, Dan Sabo wrote:

 Hi,

 I'm reading the description of Bitwise Operators on page 81 of Professional
 PHP 4, the Wrox book.  In the highlighted example on that page, the line of
 code...

 $user_permissions = CREATE_RECORDS | ALTER_RECORDS;

 the description in the book says that this line is building a set of user
 permissions out of the previously created constants with the OR operator (I
 understand what OR means).  The value of $user_permissions is set to either
 1 or 4, which is in fact 5 (0101).  But how is this single line doing that?
 The explanation was cryptic (to me).



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] RE: Bitwise operator question

2003-03-03 Thread Dan Sabo
Hi Phillip,

Don't U mean

0001
|   0100
=   0101

?

Dan

-Original Message-
From: Philip Hallstrom [mailto:[EMAIL PROTECTED]
Sent: Monday, March 03, 2003 2:33 PM
To: Dan Sabo
Cc: [EMAIL PROTECTED]
Subject: Re: Bitwise operator question


Here's how I think about it...

CREATE_RECORDS = 1 in decimal and 0001 in binary.
ALTER_RECORDS = 4 in decimal and 0101 in binary.

that line returns a binary string where *any* of the bits are 1, so line
them up:

   0001
|  0101
=  0101

which is 5.

On Mon, 3 Mar 2003, Dan Sabo wrote:

 Hi,

 I'm reading the description of Bitwise Operators on page 81 of
Professional
 PHP 4, the Wrox book.  In the highlighted example on that page, the line
of
 code...

 $user_permissions = CREATE_RECORDS | ALTER_RECORDS;

 the description in the book says that this line is building a set of user
 permissions out of the previously created constants with the OR operator
(I
 understand what OR means).  The value of $user_permissions is set to
either
 1 or 4, which is in fact 5 (0101).  But how is this single line doing
that?
 The explanation was cryptic (to me).



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] RE: Bitwise operator question

2003-03-03 Thread Philip Hallstrom
Yes.  Oops.

-philip

On Mon, 3 Mar 2003, Dan Sabo wrote:

 Hi Phillip,

 Don't U mean

   0001
 | 0100
 = 0101

 ?

 Dan

 -Original Message-
 From: Philip Hallstrom [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 03, 2003 2:33 PM
 To: Dan Sabo
 Cc: [EMAIL PROTECTED]
 Subject: Re: Bitwise operator question


 Here's how I think about it...

 CREATE_RECORDS = 1 in decimal and 0001 in binary.
 ALTER_RECORDS = 4 in decimal and 0101 in binary.

 that line returns a binary string where *any* of the bits are 1, so line
 them up:

0001
 |  0101
 =  0101

 which is 5.

 On Mon, 3 Mar 2003, Dan Sabo wrote:

  Hi,
 
  I'm reading the description of Bitwise Operators on page 81 of
 Professional
  PHP 4, the Wrox book.  In the highlighted example on that page, the line
 of
  code...
 
  $user_permissions = CREATE_RECORDS | ALTER_RECORDS;
 
  the description in the book says that this line is building a set of user
  permissions out of the previously created constants with the OR operator
 (I
  understand what OR means).  The value of $user_permissions is set to
 either
  1 or 4, which is in fact 5 (0101).  But how is this single line doing
 that?
  The explanation was cryptic (to me).
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] RE: Bitwise operator question

2003-03-03 Thread Dan Sabo
Thanks Philip,

OK I understand the binary thing but that line, I just don't see it, It's
not the or operator that's summing up the two binary values is it?

Dan

-Original Message-
From: Philip Hallstrom [mailto:[EMAIL PROTECTED]
Sent: Monday, March 03, 2003 3:53 PM
To: Dan Sabo
Cc: [EMAIL PROTECTED]
Subject: [PHP] RE: Bitwise operator question


Yes.  Oops.

-philip

On Mon, 3 Mar 2003, Dan Sabo wrote:

 Hi Phillip,

 Don't U mean

   0001
 | 0100
 = 0101

 ?

 Dan

 -Original Message-
 From: Philip Hallstrom [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 03, 2003 2:33 PM
 To: Dan Sabo
 Cc: [EMAIL PROTECTED]
 Subject: Re: Bitwise operator question


 Here's how I think about it...

 CREATE_RECORDS = 1 in decimal and 0001 in binary.
 ALTER_RECORDS = 4 in decimal and 0101 in binary.

 that line returns a binary string where *any* of the bits are 1, so line
 them up:

0001
 |  0101
 =  0101

 which is 5.

 On Mon, 3 Mar 2003, Dan Sabo wrote:

  Hi,
 
  I'm reading the description of Bitwise Operators on page 81 of
 Professional
  PHP 4, the Wrox book.  In the highlighted example on that page, the
line
 of
  code...
 
  $user_permissions = CREATE_RECORDS | ALTER_RECORDS;
 
  the description in the book says that this line is building a set of
user
  permissions out of the previously created constants with the OR operator
 (I
  understand what OR means).  The value of $user_permissions is set to
 either
  1 or 4, which is in fact 5 (0101).  But how is this single line doing
 that?
  The explanation was cryptic (to me).
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php