# Why does the \`Irrational\` type exist

**URL:** <https://discourse.julialang.org/t/why-does-the-irrational-type-exist/109586>\
**Category:** General Usage\
**Created:** [February 1, 2024, 5:42pm UTC](https://discourse.julialang.org/t/why-does-the-irrational-type-exist/109586 "2024-02-01T17:42:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alseidon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alseidon/32/207775_2.png) [@Alseidon](https://discourse.julialang.org/u/Alseidon)\
**Post date:** [February 1, 2024, 5:42pm UTC](https://discourse.julialang.org/t/why-does-the-irrational-type-exist/109586/1 "2024-02-01T17:42:09Z")

</div>

I recently stumbled upon an error writing `x->zeros(typeof(x), (2, 2))`, when I applied this to `π`. I quickly found that this was related to the `Irrational` type, which seems to be kind of a headache: [Zero(π) and one(π) are false and true?](https://discourse.julialang.org/t/zero-and-one-are-false-and-true/87802) discusses this. This leads to weird behaviours: for instance, in my case it was `Irrational(zero(π))` throwing an error (because `zero(π)` is `false`).

So is there a reason for the type to exist?

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [February 1, 2024, 5:56pm UTC](https://discourse.julialang.org/t/why-does-the-irrational-type-exist/109586/2 "2024-02-01T17:56:32Z")

</div>

Fundamentally, the goal behind the Irrationals is to seamlessly promote to higher-precision values as needed. For example, you can write `deg2rad(deg) = π * deg/180` without worrying about types — this will use a higher-precision value of pi if `deg` is a `BigFloat`.
