Size on System.Boolean variable

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

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
 
Tony said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top