Raised This Month: $ Target: $400
 0% 

true - false


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-16-2012 , 15:38   Re: true - false
Reply With Quote #3

Quote:
Originally Posted by <VeCo> View Post
Basically every number except 0, casted to boolean, returns 1 (including negative numbers).
Not true. Casting an integer to boolean does not change its value, just the tag.
So, for example:
Code:
(bool:2 == bool:1) // false (bool:1 == true) // true (bool:0 == false) // true (bool:-1 == true) // false (!!(-1) == true) // true (!!(1) == true) // true (!!(2) == true) // true (!!(0) == false) // true

When you use !, it opposites the bits in the value, so any non-zero number becomes 0 and 0's become 1.

So:
Code:
!(-1) = 0 !(0) = 1 !(1) = 0

When you use it twice, it just does the operation twice.
The result is forcing a value to be a boolean constant.

Code:
!!(2) = !(0) = 1 = true !!(0) = !(1) = 0 = false
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 06-17-2012 at 02:55.
Exolent[jNr] is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode