Skip to content

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

Open
@NHDaly

Description

@NHDaly

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions