is the bit on or off
From: WindAndWaves (access_at_ngaru.com)
Date: 07/19/04
- Next message: Spamless: "Re: is the bit on or off"
- Previous message: Cassandra Thompson: "Re: Rational numbers"
- Next in thread: Spamless: "Re: is the bit on or off"
- Reply: Spamless: "Re: is the bit on or off"
- Reply: Mensanator: "Re: is the bit on or off"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 19 Jul 2004 15:11:52 +1200
Dear Gurus
I have been trolling a few news groups, but so far unsuccessful.
I want to know if there is a simple formula that returns TRUE or FALSE for a
given number between 0 - 255. Whether the function returns true or false
depends on whether a particular bit is turned on or off:
e.g,
F(1,1) = true (or <>0) ............... 10000000
F(2,2) = true (or <>0) ............... 01000000
F(4,3) = true (or <>0) ............... 00100000
F(8,4) = true (or <>0) ............... 00010000
F(16,5) = true (or <>0) ............. 00001000
F(16,1) = false (or =0) .............. 00001000
F(17,1) = false (or =0) ............. 10001000
F(128,8) = true (or <>0)........... 00000001
Now, here is the catch... I am looking for a nice formula that is as simple
as possible (e.g. F = A^(B-1)-B). Some basic functions can be used, such as
round and int (taking the integer part), but no advanced (e.g. C++)
functions should be used, as I would like to use the formula in SQL (e.g.
the AND as a boolean operator does not work in SQL).
The SQL could look like this
SELECT * FROM TABLE WHERE ((FIELD^(N-1)-N)=true);
Where Table is random table, FIELD is a number from the table that is
between 0 and 255 and N is a number between 1 and 8.
TIA
- Nicolaas
- Next message: Spamless: "Re: is the bit on or off"
- Previous message: Cassandra Thompson: "Re: Rational numbers"
- Next in thread: Spamless: "Re: is the bit on or off"
- Reply: Spamless: "Re: is the bit on or off"
- Reply: Mensanator: "Re: is the bit on or off"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|