# What are the consequences of really big primitive types?

**URL:** <https://discourse.julialang.org/t/what-are-the-consequences-of-really-big-primitive-types/49191>\
**Category:** Internals & Design\
**Created:** [October 28, 2020, 5:27pm UTC](https://discourse.julialang.org/t/what-are-the-consequences-of-really-big-primitive-types/49191 "2020-10-28T17:27:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [October 28, 2020, 5:27pm UTC](https://discourse.julialang.org/t/what-are-the-consequences-of-really-big-primitive-types/49191/1 "2020-10-28T17:27:08Z")

</div>

one can declare arbitarily large primative types using the `primative` keyword.  
As far as i can tell they act like well behaved `isbits` types, no matter how large you make them.

[BitIntegers.jl](https://github.com/rfourquet/BitIntegers.jl) uses this to allow the creation of arbitarily large integer types. like `Int1024`

[ShortStrings.jl](https://github.com/xiaodaigh/ShortStrings.jl/) in turn uses them to allow arbitarily large “short” strings, that are efficiently stored inline as nibbles within the numbers.

Now i have tried ShortStrings backed by `Int2048` and that seemed fine.  
When i tried a ShortString backed by a `Int10240` that was less OK, and my computer basically froze up for 10 minutes when i tried to do things with it.

So what are the properties and imitations of primitive types that are large?  
The largest ones in Base (AFAIK) are `Int128` and `UInt128`.

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [October 29, 2020, 12:15pm UTC](https://discourse.julialang.org/t/what-are-the-consequences-of-really-big-primitive-types/49191/2 "2020-10-29T12:15:54Z")

</div>

One thing I discovered while investigating [https://github.com/rfourquet/BitIntegers.jl/issues/13](https://github.com/rfourquet/BitIntegers.jl/issues/13) is that for bitshifts, LLVM first converts both operands to the same type. This means that in `rand(Int1024) << 0x3`, the `0x3` will be converted to `Int1024`. I have no idea why, maybe for small primitives it makes sense, but it might be (one of) the cause of inefficient bit-shifting for big primitives.
