Skip to content

Inconsistent Integer results #154

Closed
@kimikage

Description

@kimikage

The return types of Integer(::Fixed) and Integer(::Normed) are based on different manners.

Fixed{T}: T

julia> typeof(Integer(1Q1f6))
Int8

julia> typeof(Integer(1Q1f14))
Int16

Normed: Int with (non-intuitive) promotions

julia> typeof(Integer(1N0f8))
Int64

julia> typeof(Integer(1N0f16))
Int64

julia> typeof(Integer(1N0f32))
Int64

julia> typeof(Integer(1N0f64)) # !?
BigInt

Float: Int w/o promotions

julia> typeof(Integer(Float16(1)))
Int64

julia> typeof(Integer(1.0f0))
Int64

julia> typeof(Integer(1.0))
Int64

julia> typeof(Integer(0x1p63))
ERROR: InexactError: Int64(9.223372036854776e18)

I think it is better to unify the manners, even though it will be a breaking change.
I consider it appropriate for FixedPoint to return numbers in the rawtype T as Integer(::Fixed) returns.

FYI, with fix for issue #153, we can use floor(Integer, x) etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions