summaryrefslogtreecommitdiffstats
path: root/games
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2002-07-09 02:56:10 +0000
committerpeter <peter@FreeBSD.org>2002-07-09 02:56:10 +0000
commit6eb4916dee42174b74d9d3077dd3a4b594452e66 (patch)
tree09a2ecaee506e51d20c662e00994c651c18baa1d /games
parent784b48a6bb9b28dfbe08f290b7497333d1ed9c39 (diff)
downloadFreeBSD-src-6eb4916dee42174b74d9d3077dd3a4b594452e66.zip
FreeBSD-src-6eb4916dee42174b74d9d3077dd3a4b594452e66.tar.gz
Add C code that counts the bits in a 32 bit word, right next to the C code
that reverses the bits in a 32 bit word. Who thinks up this stuff?
Diffstat (limited to 'games')
-rw-r--r--games/fortune/datfiles/fortunes8
-rw-r--r--games/fortune/datfiles/fortunes27
2 files changed, 15 insertions, 0 deletions
diff --git a/games/fortune/datfiles/fortunes b/games/fortune/datfiles/fortunes
index e88d4f9..78174a3 100644
--- a/games/fortune/datfiles/fortunes
+++ b/games/fortune/datfiles/fortunes
@@ -1417,6 +1417,14 @@ music at top volume and at least a pint of ether.
-- C code which reverses the bits in a word.
%
+ n = (n & 0x55555555) + ((n & 0xaaaaaaaa) >> 1);
+ n = (n & 0x33333333) + ((n & 0xcccccccc) >> 2);
+ n = (n & 0x0f0f0f0f) + ((n & 0xf0f0f0f0) >> 4);
+ n = (n & 0x00ff00ff) + ((n & 0xff00ff00) >> 8);
+ n = (n & 0x0000ffff) + ((n & 0xffff0000) >> 16);
+
+ -- C code which counts the bits in a word.
+%
" ... I told my doctor I got all the exercise I needed being a
pallbearer for all my friends who run and do exercises!"
-- Winston Churchill
diff --git a/games/fortune/datfiles/fortunes2 b/games/fortune/datfiles/fortunes2
index ccd3cd8..7c1f4fd 100644
--- a/games/fortune/datfiles/fortunes2
+++ b/games/fortune/datfiles/fortunes2
@@ -2707,6 +2707,13 @@ audience, either."
-- Reverse the bits in a word.
%
+ n = (n & 0x55555555) + ((n & 0xaaaaaaaa) >> 1);
+ n = (n & 0x33333333) + ((n & 0xcccccccc) >> 2);
+ n = (n & 0x0f0f0f0f) + ((n & 0xf0f0f0f0) >> 4);
+ n = (n & 0x00ff00ff) + ((n & 0xff00ff00) >> 8);
+ n = (n & 0x0000ffff) + ((n & 0xffff0000) >> 16);
+-- Count the bits in a word.
+%
Never ask your lover if he'd dive in front of an oncoming train for
you. He doesn't know. Never ask your lover if she'd dive in front of an
oncoming band of Hell's Angels for you. She doesn't know. Never ask how many
OpenPOWER on IntegriCloud