Reply to Re: Binary calculations (OR, AND, XOR)

Your name:

Reply:


Posted by Kimmo Laine on 11/21/91 11:24

"Siebie" <ceesboofUNSPAM@hotmail.com> kirjoitti
viestissδ:Xns96B8AF5583478Siebie@194.109.133.133...
> Hey,
> Anybody knows a possible way to do binary calculations (OR, AND, XOR).
> Anything I type before 'AND' will be outputted, but the AND-word and
> anything behind it is ignored. E.g.
>>>print 3 AND 1;
> results in 3.
>
> My PHP-version is 4.2.3.


Binary calculations are done with the binary (or bitwise) operators & | ^
and ~, >> and <<.

Examples:

echo (1 & 2); // Prints 0, since 0001 AND 0010 equals 0000
echo (1 | 2); // Prints 3, since 0001 OR 0010 equals 0011
echo ~(6 ^ 9) // prints 16, since NOT(0110 XOR 1001) equals !0000 equals
1111...

Etc... I just pulled the binary numbers from my hat, and my boolean math is
rusty, so errors may occur, but you get the point... And I assume this was
what you were looking for. See the manual on bitwise operators for more.

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <eternal.erectionN0@5P4Mgmail.com>

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация