# How to do arithmetic in the type system?

**URL:** <https://discourse.julialang.org/t/how-to-do-arithmetic-in-the-type-system/76565>\
**Category:** General Usage\
**Tags:** parametric-types, staticarrays\
**Created:** [February 16, 2022, 2:32pm UTC](https://discourse.julialang.org/t/how-to-do-arithmetic-in-the-type-system/76565 "2022-02-16T14:32:29Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 16, 2022, 3:17pm UTC](https://discourse.julialang.org/t/how-to-do-arithmetic-in-the-type-system/76565/4 "2022-02-16T15:17:10Z")

</div>

Instead of copying the answers from the previous discussion, I’ll just link it:

> [@Parametric type with numbers](https://discourse.julialang.org/t/parametric-type-with-numbers/74544):
>
> Hello! I am having difficulties trying to model the adequate code for what I want to achieve. Imagine I have the following struct: struct Device a::NTuple{3,Float64} b::NTuple{2,Float64} end where b is always going to be one element shorter than a. How can I generalize this for N? I figured that it would be something like struct Device{N} a::NTuple{N,Float64} b::NTuple{N-1,Float64} end but it errors because I cannot perform substraction on types. Thanks!

---

_[View the full topic](https://discourse.julialang.org/t/how-to-do-arithmetic-in-the-type-system/76565)._
