random thoughts
Monday, 7. November 2005

a question of masks

I am quite comfortable with the idea of using bit masks to test variables for specific values. What came up the other day is the need to test a byte for the presence of only a single set bit, where the specific bit is not known.

I wanted to know whether the byte had any of the following values, without caring what the actual value was;

    00000001
    00000010
    00000100
    00001000
    00010000
    00100000
    01000000

The consensus from everyone I've discussed this with is that a loop with multiple tests is required, but I can't help thinking that out there somewhere is someone that has a clever bit mask or mathematical way to test for this with a single expression.

Online for 5899 days
Last update: 12/10/10 9:58 AM
status
Youre not logged in ... Login
menu
... home
... topics
... galleries
... Home
... Tags


... Antville.org home
my other sites
search
calendar
September 2018
SunMonTueWedThuFriSat
1
2345678
9101112131415
16171819202122
23242526272829
30
December
recent updates
moving on I have succumbed
to the lure of Wordpress and have started a new...
by craniac (12/9/05 5:22 PM)
kill or cure According to
this blog entry the uninstaller that Sony has made available...
by craniac (11/16/05 11:44 AM)
sory seems to be the
hardest word In response to the Sony DRM fiasco, someone...
by craniac (11/16/05 10:49 AM)
a new internet Many years
ago I worked for a small software development company. Let's...
by craniac (11/7/05 10:03 AM)
a question of masks I
am quite comfortable with the idea of using bit masks...
by craniac (11/7/05 8:50 AM)
boycott sony! Dave Slusher over
on Evil Genius Chronicles is calling for a boycott of...
by craniac (11/4/05 11:06 AM)
car guards Here in South
Africa car theft is a big problem so every parking...
by craniac (11/4/05 9:47 AM)
pseudonym I just received a
spam e-mail from someone calling himself (or herself) Maltreatment U....
by craniac (11/2/05 1:39 PM)
the cry of the larger
breasted woman Originally posted by taminator
by craniac (10/25/05 8:59 AM)
young entrepreneur A friend sent
me this photo, which I thought was really funny.
by craniac (10/19/05 4:13 PM)

RSS Feed

Made with Antville

Creative Commons License
This work is licensed under a Creative Commons License.