scheinerman / Mods.jl

Easy modular arithmetic for Julia
MIT License
33 stars 5 forks source link

use of abstract element types not recommended #3

Closed KlausC closed 5 years ago

KlausC commented 5 years ago

See julia docu instead of

struct Mod
    val::Integer
    mod::Integer
end

you should use

struct Mod{T<:Integer}
    val::T
    mod::T
end

or even

struct Mod{T<:Unsigned} <:Real
    ...
end

The constructors should derive the concrete types from their arguments.

scheinerman commented 5 years ago

OK. I think I understand the issue and will try an update.

scheinerman commented 5 years ago

Update posted.