# Rem2pi(pi) errors

**URL:** https://discourse.julialang.org/t/rem2pi-pi-errors/133010
**Category:** Numerics
**Created:** [October 9, 2025, 1:42pm UTC](https://discourse.julialang.org/t/rem2pi-pi-errors/133010 "2025-10-09T13:42:49Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jerlich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jerlich/32/5205_2.png) [@jerlich](https://discourse.julialang.org/u/jerlich)
#### Post date: [October 9, 2025, 1:42pm UTC](https://discourse.julialang.org/t/rem2pi-pi-errors/133010/1 "2025-10-09T13:42:49Z")

</div>

There is a PR to fix, but it hasn’t been merged for 2 years.

> <https://github.com/JuliaLang/julia/pull/43539>
>
> This adds \`Irrational\` support to \`rem2pi\` and thus fixes #42799. One thing tha…t is a bit awkward is that \`rem2pi(π, r)\` returns \`π\` in the form of an \`Irrational\` for each rounding mode \_except\_ \`RoundUp\`, where it instead returns the \`Float64\` equivalent of \`-π\`. I don't expect this will lead to type instability in practice, as typically the rounding mode is fixed in the code and is thus known at compile time.
> 
> I also added a version that accepts any \`Real\`, so that e.g. the exponential constant ℯ can be passed. Admittedly, I don't see any real use case for calling with that constant in particular, but at least it works as expected now, and there are likely other, more useful, cases that will benefit from this. It also follows the practice of other methods (e.g. \`sin\`, \`cos\`), which do indeed accept this constant by converting it to a \`float\`. While making this change, I also changed the existing method specializing on \`Int64\` to specialize on \`Integer\` instead, as that method will work for any \`Integer\` that can be exactly converted to a \`Float64\`, whether it is an \`Int16\`, \`Int32\`, \`Int64\`, or even a \`BigInt\`.
