# Using uint32:1 to Create a Boolean

**URL:** <https://forums.unrealengine.com/t/using-uint32-1-to-create-a-boolean/317391>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 4, 2015, 1:26pm UTC](https://forums.unrealengine.com/t/using-uint32-1-to-create-a-boolean/317391 "2015-05-04T13:26:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_71c55af3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71c55af3](https://forums.unrealengine.com/u/anonymous_user_71c55af3)\
**Post date:** [May 4, 2015, 1:26pm UTC](https://forums.unrealengine.com/t/using-uint32-1-to-create-a-boolean/317391/1 "2015-05-04T13:26:46Z")

</div>

Actually my question is already asked, but answers didn’t made me content.

> **[Bool Types in ShooterGame | uint32 vs bool](https://forums.unrealengine.com/questions/193654/bool-types-in-shootergame-uint32-vs-bool.html)**
>
> Hey there, can someone tell me why the ShooterGame uses “unit32” types for a bool? In the ShooterWeapon Class, there are bools with the normal bool type and with uint32. Why would you use uint32 for a variable that should be true or false only? /:...

I don’t think people at epic doing things in different ways for fun. I don’t think seasoned veterans of c++ doing things from different ways for fun. There should be a reason as to why they used uint32:1 to create a boolean. Thinking that even they use a rule to add ‘b’ to boolean variable name prefixes, it probably has a very good reason.

I would love to know that reason, thanks in advance.

Please epic staff and community share your knowledges with me 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_71c55af3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71c55af3](https://forums.unrealengine.com/u/anonymous_user_71c55af3)\
**Post date:** [May 4, 2015, 1:56pm UTC](https://forums.unrealengine.com/t/using-uint32-1-to-create-a-boolean/317391/2 "2015-05-04T13:56:38Z")

</div>

Errr…

I forgot to say, at most of UE4 example projects and source code of UE4. uint32:1 is used to create a boolean.

Forgot the most important part in my question.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8e2766aa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8e2766aa](https://forums.unrealengine.com/u/anonymous_user_8e2766aa)\
**Post date:** [May 4, 2015, 2:12pm UTC](https://forums.unrealengine.com/t/using-uint32-1-to-create-a-boolean/317391/3 "2015-05-04T14:12:50Z")

</div>

Hello,

You are absolutely right - there is a logical reason behind this. uint 32 is used to create a Boolean because of bit fields and alignment. Basically, these are the tools that allow more effective memory management.  
If you like to learn more about bit fields, please go here:

> **[C++ Bit Fields](https://learn.microsoft.com/en-us/cpp/cpp/cpp-bit-fields?redirectedfrom=MSDN&view=msvc-170)**
>
> Learn more about: C++ Bit Fields

Hope this helped! Good luck!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_71c55af3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71c55af3](https://forums.unrealengine.com/u/anonymous_user_71c55af3)\
**Post date:** [May 4, 2015, 3:05pm UTC](https://forums.unrealengine.com/t/using-uint32-1-to-create-a-boolean/317391/4 "2015-05-04T15:05:25Z")

</div>

I actually know about bitfield to some degree and that article helped some.

Just to confirm, if i use uint32:1 i will just have 1 bit while i use a bool i will have 32 or 64 bits and many bits wasted. This way we are saving memory, right?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8e2766aa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8e2766aa](https://forums.unrealengine.com/u/anonymous_user_8e2766aa)\
**Post date:** [May 4, 2015, 3:40pm UTC](https://forums.unrealengine.com/t/using-uint32-1-to-create-a-boolean/317391/5 "2015-05-04T15:40:31Z")

</div>

Yes, you are right. You see, a bool should be at least one byte long (due to processor limitations). However, since there are 8 bits in a byte it has enough space to keep 8 bits (or 8 bools).  
Thus, if you have a data structure featuring multiple bools, you don’t have to specify a byte for each - one byte can be shared.
