Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Delphi
  4. Why is boolean true represented as -1?

Why is boolean true represented as -1?

Scheduled Pinned Locked Moved Delphi
question
3 Posts 2 Posters 15 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 12941702
    wrote on last edited by
    #1

    I just wrote a program and used the BoolToStr() function to convert the boolean value true to a string so I could read it in a WriteLn statement. Much to my surprise the screen represented true as -1. Can someone explain?

    L 1 Reply Last reply
    0
    • U User 12941702

      I just wrote a program and used the BoolToStr() function to convert the boolean value true to a string so I could read it in a WriteLn statement. Much to my surprise the screen represented true as -1. Can someone explain?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Because internally they're numbers, no text.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

      U 1 Reply Last reply
      0
      • L Lost User

        Because internally they're numbers, no text.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

        U Offline
        U Offline
        User 12941702
        wrote on last edited by
        #3

        I meant why is boolean true represented as a negative number instead of a positive number. Like in C++ boolean true is represented as 1. But I guess since true is represented by any non-zero integer I can see why -1 works just as good.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups