Size on System.Boolean variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Johansson

    #1

    Size on System.Boolean variable

    Hello!

    What can the reason be for making a System.Boolean as big as 4 bytes.
    It's only true or false.

    I imagine the variable type of a boolean could have been made much smaller.

    //Tony


  • Jeroen Mostert

    #2
    Re: Size on System.Boolean variable

    Tony Johansson wrote:
    What can the reason be for making a System.Boolean as big as 4 bytes.
    It's only true or false.
    >
    Alignment. A 32-bit integer is faster to process than a single byte.
    I imagine the variable type of a boolean could have been made much smaller.
    >
    Yes, but memory size is generally cheaper than memory access.

    There's BitVector32 for optimized storage if it's needed.

    --
    J.

    Comment

    Working...