Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Misc > Re: Boolean =?I...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 6074 of 6160
Post > Topic >>

Re: Boolean =?ISO-8859-1?Q?incompr=E9hensible?=

by Hans-Peter Diettrich <DrDiettrich1@[EMAIL PROTECTED] > Jun 15, 2008 at 10:55 AM

Jamie schrieb:

>>       if (7 and x)=5 then showmessage('true');

> That is a logical AND..

Not exactly. It's a *bitwise* (arithmetic) AND, not a logical (boolean) 
one. The result is an integral (ordinal) value, not a boolean one. This 
difference may have confused the OP.

>  7 = 111 in binary
>  5 = 101 in binary


In addition to your explanation of bit manipulation, one also can think 
in SETs, where a byte is equivalent to an

type
   Toctet = set of 0..7;
....
   TDWORD = set of 0..31;

and the above values correspond to

const
   sept = [1,2,4]; //1+2+4 = 7
   cinq = [1,4];   //1 + 4 = 5

Then SET operations can be used for testing, setting and clearing bits:
   set becomes Include()
   clr becomes Exclude()
   OR  becomes + (union)
   AND becomes * (intersection)
   XOR becomes - (difference)
....
[just from memory, please check the set operators in online help]

Using sets can result in more transparent handling of bitmasks, e.g. in 
API calls. Unfortunately the C language has enums, but no equivalent for 
sets, so that overloaded versions of the API functions were required, or 
typecasts, for passing sets as integral values :-(

DoDi
 




 7 Posts in Topic:
Boolean incompréhensible
"jg07" <jg07  2008-06-14 23:08:02 
Re: Boolean =?windows-1252?Q?incompr=E9hensible?=
Jamie <jamie_ka1lpa_no  2008-06-14 17:42:44 
Re: Boolean =?ISO-8859-1?Q?incompr=E9hensible?=
Hans-Peter Diettrich <  2008-06-15 10:55:20 
Re: Boolean incompréhensible
"Maarten Wiltink&quo  2008-06-15 13:04:02 
Re: Boolean incompréhensible
"jmverdi" <j  2008-06-15 00:02:18 
Re: Boolean =?windows-1252?Q?incompr=E9hensible?=
Jamie <jamie_ka1lpa_no  2008-06-14 18:33:56 
=?UTF-8?Q?Re=3A_Boolean_incompr=EF=BF=BDhensible?=
"alanglloyd@[EMAIL P  2008-06-15 01:23:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 9:56:26 CDT 2008.