# Constructors for Primitive types

**URL:** https://discourse.julialang.org/t/constructors-for-primitive-types/19139
**Category:** General Usage
**Tags:** question, faq, type
**Created:** [December 30, 2018, 11:07pm UTC](https://discourse.julialang.org/t/constructors-for-primitive-types/19139 "2018-12-30T23:07:45Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![bennedich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bennedich/32/4894_2.png) [@bennedich](https://discourse.julialang.org/u/bennedich)
#### Post date: [December 30, 2018, 11:52pm UTC](https://discourse.julialang.org/t/constructors-for-primitive-types/19139/2 "2018-12-30T23:52:41Z")

</div>

Try this:

```julia
primitive type Basis{V,G} <: Unsigned 16 end

Basis{V,G}(x::UInt16) where {V,G} = reinterpret(Basis{V,G}, x)

UInt16(x::Basis) = reinterpret(UInt16, x)

Base.show(io::IO, x::Basis) = print(io, UInt16(x))

Basis{4,3}(0x0007)

```

---

_[View the full topic](https://discourse.julialang.org/t/constructors-for-primitive-types/19139)._
