# Why is @enum 0-based?

**URL:** <https://discourse.julialang.org/t/why-is-enum-0-based/12722>\
**Category:** General Usage\
**Tags:** enum\
**Created:** [July 29, 2018, 1:37pm UTC](https://discourse.julialang.org/t/why-is-enum-0-based/12722 "2018-07-29T13:37:04Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [October 7, 2019, 11:49pm UTC](https://discourse.julialang.org/t/why-is-enum-0-based/12722/5 "2019-10-07T23:49:49Z")

</div>

> [@gdkrmr](#):
>
> Arrays in Julia are 1-based, so why are Enums 0-based?

Because enums aren’t arrays? They are a wrapper for a kind of integer type, and integer types on a computer have values that generally start at `0`, especially for unsigned types.

You might as well ask why `UInt8` values go from `0` to `255` and not `1` to `256`, or why `Bool` values are equivalent to `0` and `1` rather than `1` and `2`.

Indeed, you can define an `@enum` to be a wrapper around an unsigned integer or a boolean value, in which case starting the numbering at `1` by default would allow fewer possible values. For example, `@enum Switch::Bool begin Off; On; end` couldn’t work.

---

_[View the full topic](https://discourse.julialang.org/t/why-is-enum-0-based/12722)._
