Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9165853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:00:25+00:00 2026-06-17T15:00:25+00:00

I was wondering why True is equal to -1 and not 1. If I

  • 0

I was wondering why True is equal to -1 and not 1. If I remember correctly (back in the days) in C, “true” would be equal to 1.

    Dim t, f As Integer

    t = True
    f = False

    Console.WriteLine(t) ' -1
    Console.WriteLine(f) ' 0
    Console.ReadLine()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:00:27+00:00Added an answer on June 17, 2026 at 3:00 pm

    When you cast any non-zero number to a Boolean, it will evaluate to True. For instance:

    Dim value As Boolean = CBool(-1) ' True
    Dim value1 As Boolean = CBool(1) ' True
    Dim value2 As Boolean = CBool(0) ' False
    

    However, as you point out, any time you cast a Boolean that is set to True to an Integer, it will evaluate to -1, for instance:

    Dim value As Integer = CInt(CBool(1)) ' -1
    

    The reason for this is because -1 is the signed-integer value where all of its bits are equal to 1. Since a Boolean is stored as a 16-bit integer, it is easier to toggle between true and false states by simply NOT’ing all of the bits rather than only NOT’ing the least significant of the bits. In other words, in order for True to be 1, it would have to be stored like this:

    True  = 0000000000000001
    False = 0000000000000000
    

    But it’s easier to just store it like this:

    True  = 1111111111111111
    False = 0000000000000000
    

    The reason it’s easier is because, at the low-level:

    1111111111111111 = NOT(0000000000000000)
    

    Whereas:

    0000000000000001 <> NOT(0000000000000000)
    0000000000000001 = NOT(1111111111111110)
    

    For instance, you can replicate this behavior using Int16 variables like this:

    Dim value As Int16 = 0
    Dim value2 As Int16 = Not value
    Console.WriteLine(value2) ' -1
    

    This would be more obvious if you were using unsigned integers, because then, the value of True is the maximum value rather than -1. For instance:

    Dim value As UInt16 = CType(True, UInt16) ' 65535
    

    So, the real question, then, is why in the world does VB.NET use 16 bits to store a single bit value. The real reason is speed. Yes, it uses 16 times the amount of memory, but a processor can do 16-bit boolean operations a lot faster than it can do single-bit boolean operations.

    Side note: The reason why the Int16 value of -1 is stored as 1111111111111111 instead of as 1000000000000001, as you might expect (where the first bit would be the “sign bit”, and the rest would be the value), is because it is stored as the two’s-complement. Storing negative numbers as the two’s-complement means that arithmetic operations are much easier for the processor to perform. It’s also safer because, with two’s-compliment, there’s no way to represent 0 as a negative number, which could cause all sorts of confusion and bugs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering why my php program is not returning the correct TRUE FALSE
I was wondering , Why would I ever want to pass a true in
I was reading about inverse = true in one-to-many relation and was actually wondering
Wondering what the best / good way of doing this would be in jQuery.
Hey, I was wondering if setting an object equal to $.extend(), but setting the
I was wondering why to equal points cannot be compared and shown as equal
I am wondering why in C# 0 == 0 // return true (object) 0
I am wondering if this is true: When I take the square root of
Hi all I was wondering is it true that the first-language of monitors is
I'm wondering, in PHP, I've seen people use both these cases: if($var === TRUE)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.