Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for numerator(::FD) and denominator(::FD) #56

Open
NHDaly opened this issue Jun 9, 2020 · 0 comments
Open

Add support for numerator(::FD) and denominator(::FD) #56

NHDaly opened this issue Jun 9, 2020 · 0 comments

Comments

@NHDaly
Copy link
Member

NHDaly commented Jun 9, 2020

We already support converting a FixedDecimal to a Rational, via:

function Base.convert(::Type{TR}, x::FD{T, f}) where {TR <: Rational, T, f}
convert(TR, x.i // coefficient(FD{T, f}))::TR
end

We should also provide numerator() and denominator(), as part of that interface. They might be implemented like this:

function Base.numerator(x::FixedDecimal{T,f})::T where {T, f}
    return value(x)
end
function Base.denominator(x::FixedDecimal{T,f})::T where {T, f}
    return coefficient(x)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant