# Bitmask Enum incorrect values

**URL:** <https://forums.unrealengine.com/t/bitmask-enum-incorrect-values/371240>\
**Category:** C++\
**Tags:** ENUM, unreal-engine, question\
**Created:** [September 22, 2016, 9:23am UTC](https://forums.unrealengine.com/t/bitmask-enum-incorrect-values/371240 "2016-09-22T09:23:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ungalyant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ungalyant](https://forums.unrealengine.com/u/Ungalyant)\
**Post date:** [September 22, 2016, 9:23am UTC](https://forums.unrealengine.com/t/bitmask-enum-incorrect-values/371240/1 "2016-09-22T09:23:39Z")

</div>

I have a bitmask enum I’ve declared in the following manner:

```
UENUM(BlueprintType, meta = (Bitflags))
enum class EDoorKeys : uint8
{
	Key1= 1 UMETA(DisplayName = "Some Key"),
	Key2 2 UMETA(DisplayName = "Some Key 2"),
	Key3 = 4 UMETA(DisplayName = "Some Key 3"),
	Key4 = 8 UMETA(DisplayName = "Some Key 4"),
	Key5 = 16 UMETA(DisplayName = "Some Key 5"),
	Key 6 = 32 UMETA(DisplayName = "Some Key 6")
};
ENUM_CLASS_FLAGS(EDoorKeys)

```

I’m using in an actor as follows:

```
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Variables|Inventory",
		meta = (Bitmask, BitmaskEnum = "EDoorKeys"))
		int32 currentKeys2;

```

However when I’m checking its values as I’m manipulating it, Key1 maps to a value of 2; Key 2 maps to a value of 4; Key3 maps to a value of 16; Key 4 maps to a value of 256; Key5 maps to a value of 65,536 and Key6 is unusable.

Oddly, when I print out the value of one of the enum values on its own I.e:

```
GEngine->AddOnScreenDebug(....FString::FromInt((int)EDoorKeys::KeyX);

```

It prints out the value I would expect, Where X is 1 or 6, I’d get 1 or 32.

I’ve tried changing the values to use a hexadecimal value instead in case that did something, but to no avail, I also tried using the actor variable as a uint8, but then I only have access to the first 3 options. Does anyone have any ideas?

---

<div class="post-metadata">

**Author:** ![Ungalyant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ungalyant](https://forums.unrealengine.com/u/Ungalyant)\
**Post date:** [September 22, 2016, 4:07pm UTC](https://forums.unrealengine.com/t/bitmask-enum-incorrect-values/371240/2 "2016-09-22T16:07:22Z")

</div>

Having looked around a bit more, it seems this issue is covered by bug UE-32816.

The bug outlines that it is actually as intended functionality, and the bitmask values, rather than 1, 2, 4, 8 … it should simply be 1, 2, 3, 4, 5… where the value is actually interpreted as 1 \<\< N rather than N itself.

I’m unsure if I should delete my post at this point or leave this here for posterity.

---

<div class="post-metadata">

**Author:** ![pdjek](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@pdjek](https://forums.unrealengine.com/u/pdjek)\
**Post date:** [November 8, 2021, 10:19am UTC](https://forums.unrealengine.com/t/bitmask-enum-incorrect-values/371240/3 "2021-11-08T10:19:17Z")

</div>

Adding a link to the doc, for other people to see: [Properties | Unreal Engine 4.27 Documentation](https://docs.unrealengine.com/4.27/en-US/ProgrammingAndScripting/GameplayArchitecture/Properties/#asbitmasks)  
If you want to use enum values as bitflags, you can use the meta tag UseEnumValuesAsMaskValuesInEditor.
