Skip to content

Problems with conversions from Rational #157

@kimikage

Description

@kimikage

Normed supports the conversion to Rational, but does not support the conversion from Rational.

julia> N0f8(1//2)
ERROR: MethodError: no method matching unsafe_trunc(::Type{UInt8}, ::Rational{Int64})

Fixed supports the conversion from Rational, but it overflows too easily.

julia> Q0f7(1//2)
ERROR: InexactError: trunc(Int8, 128)

Fixed{T,f}(x::Rational) where {T,f} = Fixed{T,f}(x.num)/Fixed{T,f}(x.den)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions