Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BOOL Datatype
Message
From
10/04/2000 17:08:18
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00357504
Message ID:
00357703
Views:
17
>>I'm surprised, too - every language I've studied (I haven't studied BASIC :-)) uses 0 for FALSE, and a non-zero positive integer (usually 1, as you noted) for TRUE.
>
>Al,
>
>I'm not sure why you're surprised. C++ does use a non-zero value positive integer, 1. VB, OTOH, uses -1. The latter I can understand because regardless of the number of bytes, the bitwise compliment (NOT 0, or in VFP BITNOT(0)) of 0 (False) will be -1. Defining True recursively as NOT False makes more sense to me than defining it independently.

I'm surprised because I hadn't heard of ANY language that used -1 for TRUE.

I don't see why TRUE *must* be defined as the bitwise complement of the value of FALSE. As I see it, TRUE is just a placeholder that needs to be defined so that boolean operations proceed as expected; it just has to be different from FALSE. If it makes sense from a storage efficiency standpoint to define it as +1, then why not do so?

Defining TRUE as a constant is more efficient than recursively defining it as NOT FALSE. Looking at the command:

X = TRUE

If TRUE is defined as 1 (or -1, or anything else non-zero) then all that has to happen at runtime is the value is stored.

If TRUE is NOT FALSE, then the value of FALSE must be NOTted (bitwise complement, whatever) at runtime, then the result stored.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform