Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BOOL Datatype
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00357504
Message ID:
00357765
Views:
17
>Now in regards to C++ and specifically the API, there are a number of functions that return a BOOL (Boolean) data type. Like VB, logical false will be equal to zero. Unlike, VB (and the result of performing a bitwise NOT on 0), these functions return 1 rather than -1. I'm just wondering if anyone knows why.
>

The BOOL operator really works at the bit-level, but without masking the result, it returns at least a byte, in VFP, a value of byte size or larger is the limit of visibility. BOOL operates on the assumption that any visible non-zero result is TRUE - if you need to mask a bit, you AND the result.

>My curiousity got piqued when I recently upsized a table to SQL server. In that environment, Boolean fields are stored as a bit. Naturally, -1 isn't really possible there, since you'd need at least a second bit to determine the sign. However, I sincerely doubt that C++ would do something similar since the smallest portion of addressable memory is a byte, and breaking a byte down into 8 individual BOOLs seems rather silly, not to mention the overhead difficulties that would be created.
>

That not really true - there are LOTS of structs that use individual bits to designate boolean condition (oy - just try digging around inside a PIF some time) and the cost of a logical AND operator is very small in C.

You make some bad assumptions - many of the C structures are designated as machine-dependent; a ULONG and a DWORD are not necessarily the same if you move out of the Win32 platform.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform