[AccessD] OT: Programming Logic

Drew Wutka DWUTKA at marlow.com
Fri Feb 14 18:21:00 CST 2003


AND

If 1 AND x Then

The 'numbers' you are seeing are bits.  In one byte (8 bits), you have the
numbers 0 to 255.  All bits off is 0, all bits on is 255.  The bits
themselves are 1,2,4,8,16,32,64,128.  Add them all up, and you get 255.  You
can get any number between 0 and 255 by using a combination of the numbers.
That is binary.  (Base 10 is similar.  The first position is the ones column
(as with any base...including binary), the second is the 10's column (thus
in binary, the second position is the 2's column).

To determine what column represents what, you take the position x, and use
this:  Base^(x-1)

Also, the highest 'number' in any base is one less then the base.  Thus in
base 10, you have 0 through 9....no 10, because a 10 is really a 1 in the
tenths place and a 0 in the ones.  That is why binary is all ones and
zeros...it's base 2.  Higher bases such as hex use letters to represent
place holders higher then 9.

Anyhow, as I said at the top, AND is what you are looking for.  1 AND 4  is
false, because the 1 bit is not on to represent the number four (only the 4
bit is turned on well, the third bit).

I hope that answers your question.

Drew

-----Original Message-----
From: Joe Rojas [mailto:JRojas at tnco-inc.com]
Sent: Friday, February 14, 2003 2:27 PM
To: 'accessd at databaseadvisors.com'
Subject: [AccessD] OT: Programming Logic


Hi All,

	I have seen in a couple of programs that use flags to set options
that work by giving a "binary" value, if you will, to each setting. For
example, the first setting has the value 1, the second 2, then 4,
8,16,32,64,etc. Then it will add up the values of the settings that have
been turned on. So if the 3rd, 5th, and 7th settings were turned on the
value would be 84 (4+16+64). The totaled value generated would be unique,
i.e. no two combinations of settings would produce the same totaled value.

	Here is the part that I get stumped on...how would one program a
function that would take a totaled value and "break it up" into the
individual values that made it up? For example, if given the value 84, it
would "break it up" as 4, 16, and 64.

Any ideas would be appreciated.

Thanks,
Joe Rojas





This electronic transmission is strictly confidential to TNCO, Inc. and
intended solely for the addressee. It may contain information which is
covered by legal, professional, or other privileges. If you are not the
intended addressee, or someone authorized by the intended addressee to
receive transmissions on behalf of the addressee, you must not retain,
disclose in any form, copy, or take any action in reliance on this
transmission. If you have received this transmission in error, please notify
the sender as soon as possible and destroy this message. While TNCO, Inc.
uses virus protection, the recipient should check this email and any
attachments for the presence of viruses. TNCO, Inc. accepts no liability for
any damage caused by any virus transmitted by this email.
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list