# Extend \`mod\` first argument to Gaussian integers?

**URL:** https://discourse.julialang.org/t/extend-mod-first-argument-to-gaussian-integers/45975
**Category:** Internals & Design
**Created:** [September 2, 2020, 9:49pm UTC](https://discourse.julialang.org/t/extend-mod-first-argument-to-gaussian-integers/45975 "2020-09-02T21:49:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![scheinerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scheinerman/32/35303_2.png) [@scheinerman](https://discourse.julialang.org/u/scheinerman)
#### Post date: [September 2, 2020, 9:49pm UTC](https://discourse.julialang.org/t/extend-mod-first-argument-to-gaussian-integers/45975/1 "2020-09-02T21:49:17Z")

</div>

Would folks find it useful if `mod(z,m)` worked when `z` is a Gaussian integer? This is easy enough to implement:

```julia
import Base.mod

function mod(z::Complex{T}, m::Integer) where T<:Integer 
    a,b = reim(z)
    return mod(a,m) + mod(b,m)*im 
end 

```

I’m wondering if this should be included in `Base`?

---

<div class="post-metadata">

### Author: ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)
#### Post date: [September 3, 2020, 1:29am UTC](https://discourse.julialang.org/t/extend-mod-first-argument-to-gaussian-integers/45975/2 "2020-09-03T01:29:51Z")

</div>

In the package `Grassmann` I implemented such a method which applies `mod` to each coefficient in the `TensorAlgebra`, so I don’t see any issue with doing the same for `Complex` also. It wouldn’t cause any issues as far as I am aware. Try making a PR?

---

<div class="post-metadata">

### Author: ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)
#### Post date: [September 3, 2020, 8:40am UTC](https://discourse.julialang.org/t/extend-mod-first-argument-to-gaussian-integers/45975/3 "2020-09-03T08:40:07Z")

</div>

Have a look at [https://github.com/JuliaLang/julia/pull/35374](https://github.com/JuliaLang/julia/pull/35374). If you are interested in this, fell free to bump that PR.

---

<div class="post-metadata">

### Author: ![scheinerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scheinerman/32/35303_2.png) [@scheinerman](https://discourse.julialang.org/u/scheinerman)
#### Post date: [September 3, 2020, 1:31pm UTC](https://discourse.julialang.org/t/extend-mod-first-argument-to-gaussian-integers/45975/4 "2020-09-03T13:31:29Z")

</div>

Thanks folks, but I’m sufficiently inept at git that I wouldn’t know how to do the things you suggest. I’m just going to add `Complex` support to my `Mods` package.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [September 3, 2020, 1:53pm UTC](https://discourse.julialang.org/t/extend-mod-first-argument-to-gaussian-integers/45975/5 "2020-09-03T13:53:08Z")

</div>

> [@simeonschaub](#):
>
> Have a look at [https://github.com/JuliaLang/julia/pull/35374](https://github.com/JuliaLang/julia/pull/35374). If you are interested in this, fell free to bump that PR.

That PR only has `mod(::Complex, ::Complex)`, unless I’m missing something?

I filed an issue ([mod(::Complex{\<:Integer}, ::Integer) and div etc. · Issue #37376 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/37376)) — should be an easy first PR for someone wants to get their feet wet with contributing to Julia.
