# How is boolean represented in memory?

**URL:** <https://forum.kirupa.com/t/how-is-boolean-represented-in-memory/300852>\
**Category:** programming\
**Created:** [November 28, 2009, 10:46pm UTC](https://forum.kirupa.com/t/how-is-boolean-represented-in-memory/300852 "2009-11-28T22:46:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeoDreamer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NeoDreamer](https://forum.kirupa.com/u/NeoDreamer)\
**Post date:** [November 28, 2009, 10:46pm UTC](https://forum.kirupa.com/t/how-is-boolean-represented-in-memory/300852/1 "2009-11-28T22:46:30Z")

</div>

How are booleans represented in memory? If you had 8 booleans declared one after another, will they be packed tightly in 1 byte?

How are booleans retrieved? No OS will actually fetch 1 bit, right? They must grab an entire word (16 bits in Unix, I believe). If this is so, then wouldn’t it be faster to use ints instead of bools? Because the bool would have to be extracted out of the retrieved word (with an XOR???) whereas the int can be used directly.
