# 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:** 4

<div class="post-metadata">

### Author: ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)
#### Post date: [December 29, 2017, 12:32pm UTC](https://discourse.julialang.org/t/how-to-write-bits-into-a-user-defined-primitive-type/8053/4 "2017-12-29T12:32:48Z")

</div>

This topic might also be of interest (this isn’t the first time people have wanted to use a 24-bit primitive type):

> [@Regression between v0.6 and master with reinterpret from #21831](https://discourse.julialang.org/t/regression-between-v0-6-and-master-with-reinterpret-from-21831/4040):
>
> On v0.6.0-rc2, this works: julia\> primitive type Foo 24 end ; reinterpret(Foo, b"123") 1-element Array{Foo,1}: Foo(0x333231) On v0.7.0-DEV.427, it fails: julia\> primitive type Foo 24 end ; reinterpret(Foo, b"123") ERROR: ArgumentError: reinterpret from alignment 1 bytes to alignment 4 bytes not allowed Stacktrace: [1] reinterpret(::Type{Foo}, ::Array{UInt8,1}, ::Tuple{Int64}) at ./array.jl:160 [2] reinterpret(::Type{Foo}, ::Array{UInt8,1}) at ./array.jl:139 This seems to be another regres…

---

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