This is really more about VC++ than VFP, but it's something that I've wondered about for a long period of time, and I'm hoping that someone out there might know the answer. First, a bit of background.
Back when I was working in QuickBASIC, it was not uncommon to see something like this:
CONST FALSE% = 0
CONST TRUE% = NOT FALSE
Note that this code pre-dates the boolean data types of False and True currently available in VB. What the code above does in the first line is assign the value of 0 to the constant. The second line performs a bitwise NOT on the assigned constant and assigns the result to another constant. As a result of the above the TRUE constant had a value of -1. In fact, these same values correspond to the ones used by VB for its Booleans today.
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.
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.
Any comments would be appreciated.
George
Ubi caritas et amor, deus ibi est