Skip to content

repr(::Float128) is broken #84

Description

@dzhang314

In Julia, repr(x) is supposed to return valid Julia code that can be executed to reconstruct an object equivalent to x. For example, repr(::Float16) and repr(::Float32) add annotations to x indicating its type:

julia> repr(Float16(1))
"Float16(1.0)"

julia> repr(Float32(1))
"1.0f0"

However, repr(::Float128) fails to do this, and evaluating its result yields a Float64.

julia> repr(Float128(1))
"1.00000000000000000000000000000000000e+00"

julia> 1.00000000000000000000000000000000000e+00 |> typeof
Float64

In particular, repr(::Float128) is completely broken for Inf128 and NaN128, which are currently formatted as inf and nan.

julia> repr(Float128(Inf))
"inf"

julia> repr(Float128(NaN))
"nan"

julia> inf
ERROR: UndefVarError: `inf` not defined

julia> nan
ERROR: UndefVarError: `nan` not defined

These should format as Inf128 and NaN128 (see #83) respectively.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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