Thanks:  0
Likes:  0
Dislikes:  0

1. ## interesting fact about boolean values

a=1
b=0

msgbox cbool(a)

msgbox cbool(b)

msgbox cint(true) '-1 ;interesting isn't it?

Great!

3. ## Re: interesting fact about boolean values

That 's why when checking if a condition is true we use:

if (condition&lt;&gt;0) 'which it means not false, also it means true, so -1 means True (not false)

Example1:

if (cint(true)) then
msgbox "true"
else
msgbox "False"
end if

Example2:
if not (cint(true)) then
msgbox "true"
else
msgbox "False"
end if

4. ## Re: interesting fact about boolean values

My point was, why they chose "-1" for true? why not +1?
msgbox cint(true) prints "-1"

5. ## Re: interesting fact about boolean values

[ QUOTE ]
msgbox cint(true) '-1 ;interesting isn't it?

[/ QUOTE ]
TRUE and FALSE are a constant. While FALSE is 0 and TRUE is not being FALSE. But since TRUE constant has to take a value it was given -1.

CBool is based on the logic while TRUE constant is based on the one of the possible values

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.