Quote:
Originally Posted by <VeCo>
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
__________________