As the name of the variable type byte , its size is equal to one byte. And, indeed,

 sizeof(byte); 

Will return 1. But

 sizeof(boolean); 

also returns 1, although theoretically boolean stores one bit of information. On a variable it is impossible to select a fractional number of bytes, or what?

1 answer 1

Just like char or byte , boolean takes 1 byte (8 bits) to store the values ​​1 or 0, true / false .

A boolean data type can be implemented and stored in memory using only one bit, but usually the minimum addressable memory cell (byte or machine word) is used as a more efficient performance unit when working with processor registers and RAM .

PS in some languages ​​reserved 2 bytes.

  • one
    there are two and four byte bulls :) - Grundy
  • Throw off please the link to 4 byte buly. Thank you. - Maksym Malishchuk
  • With a minus answer, I suggest specifying what it is wrong with, or writing your own. Thank. - Risto
  • @MaksymMalishchuk, link to the documentation in question - Grundy 6:55 pm
  • one
    The phrase about the values ​​0 and 1 is not quite correct if we take the general definition, and not just for FreePascal. Different languages ​​keep True differently. There is only one convergence: False is 0. But True in Delphi = -1 ($ FF), in FreePascal and in C (emnip) = 1 ($ 1). But this is setting the value. But the verification (comparison) is carried out according to the only definite condition (the compiler assumes it): 0 = False, not 0 = True, otherwise it would not be possible to dock with other languages. - kami