Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - In vb, what becomes-1 for true, 0 for false, and under what circumstances is non-0 true and 0 for false?
In vb, what becomes-1 for true, 0 for false, and under what circumstances is non-0 true and 0 for false?
True and False are two constants declared internally by VB, but they are actually integers, where the value of True is-1 and the value of False is 0. Why? Let's look at the binary form of these two numbers:

true(- 1): 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 165438

False(0):0000000000000000

It can be seen that the values of these two numbers are opposite in every bit, so they are real opposites, which are suitable for expressing logical values such as "either/or", "right and wrong" and "right and wrong".

And "non-zero is true and zero is false" is true in any case, because when converting numerical values into Boolean values, numbers need to be divided into two categories (otherwise, are the other two categories true or false? ), it is most appropriate to use "zero" and "non-zero" to classify at this time.