Skip to content

Missing methods for Float16 - Integer comparison #29743

Closed
@RalphAS

Description

@RalphAS

Currently comparisons between Float16 and integer types fall back to using promote_type (instead of specific methods as for other floating point types). The promotion goes to Float16. This leads to the following sort of errors and inconsistencies:

julia-1.1> Inf16 == typemax(Int)
true

julia-1.1> Inf16 == 10^5
true

Compare:

julia-1.1> Inf16 == 1.0e5  # promotion works for float-float comparisons
false

julia-1.1> Inf32 <= typemax(UInt128)
false

julia-1.1> Float32(typemax(UInt128))
Inf32  # overflow is ok when it doesn't confound comparisons

Verified on a variety of Julia versions from 0.6.4 through a recent nightly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestGood for Hacktoberfest participantsgood first issueIndicates a good issue for first-time contributors to Julia

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions