Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BOOL Datatype
Message
 
To
10/04/2000 16:23:47
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00357504
Message ID:
00357693
Views:
16
>Hi George. In my meager or extensive experence with C/C++ (how ever you might want to look at it). A boolean value is not a data type like a byte, word, integer or long, but rather any one of these data types can be used in a boolean expression.
>
>For instance, say you have an Integer (32-bits), where each bit of the integer represents something (attributes on a file is a good example). Here is one example of what I mean.
>
>-----
>#define byte_1 1;
>#define byte_2 2;
>#define byte_3 4;
>...
>#define byte_9 512;
>...
>#define byte_11 2048;
>... And So on ...
>
>if (file_att & byte_11)
> MessageBox(0, "File is Read Only", "Message", MB_OK);
>
>
>------
>In the previous example, the if statement does a boolean comparision. The if statement can also be written as:
>
>if ((file_att & byte_11) == true)
> MessageBox(0, "File is Read Only", "Message", MB_OK);
>
>// or
>
>if (!(file_att & byte_11))
> MessageBox(0, "!!! File Not read only", "message", MB_OK);
>
>-----------------
>
>If you look closely at all IF statements in C/C++, you'll notice that they all boil down to a true or false result. False will equal 0, but true can be anything that is not equal to 0. So the following code will always evaluate to true and keep looping.
>
>-------
>
>unsigned int counter = 1;
>
>while (counter) counter++;
>
>-------
>
>Note: That is, until counter reaches it's maximum value and rolls over to 0. Then the loop will finish.
>
>As for the size of a boolean value, a boolean value can be stored in any numerical data type (ie. long, DWORD, unsigned int, ...). When you are storing a boolean value, you would want to use the smallest available data type (a char is only 1 byte long). SQL Server probably stores a Bit value in something at least the size of one byte.
>
>Well, thats the world of a boolean value in c/c++ according to Rob. I hope that helps you.
>
>P.S. Just for fun, put BOOLEAN zing = 55; in a program and compile it, I'll bet that it wont give you an error and if you test the value, it will equal 55.
>
Thanks, Rob. I was aware this, I just found it curious that in defining Boolean true it was not done recursively based on false. This came mainly from my work with the Win32 API. Typically any of the function which return a BOOL, return 0 or 1 (in VFP). It was more a curiousity than anything else.
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform