# How to write bits into a user-defined primitive type?

**URL:** <https://discourse.julialang.org/t/how-to-write-bits-into-a-user-defined-primitive-type/8053>\
**Category:** General Usage\
**Created:** [December 29, 2017, 12:31am UTC](https://discourse.julialang.org/t/how-to-write-bits-into-a-user-defined-primitive-type/8053 "2017-12-29T00:31:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [December 29, 2017, 7:21am UTC](https://discourse.julialang.org/t/how-to-write-bits-into-a-user-defined-primitive-type/8053/3 "2017-12-29T07:21:49Z")

</div>

This may help:

> [@Convert to and from Int24](https://discourse.julialang.org/t/convert-to-and-from-int24/7670):
>
> I am want to try an Int24 type, purely for storage. It is easy to declare one with primitive type Int24 \<: Signed 24 end but I am not sure how to access its value. I only need conversion to and from Int32, but I don’t think I can use reinterpret because they don’t have the same number of bits. How can I convert to and from Int32? (BTW, I am aware that I destroy alignment and it will degrade performance; it is an experiment)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-write-bits-into-a-user-defined-primitive-type/8053)._
