This caught me by surprise:
julia> parse(Float32, "1.0f0")
ERROR: ArgumentError: cannot parse "1.0f0" as Float32
Float32
seems special
julia> x = UInt8(1)
0x01
julia> parse(typeof(x), repr(x))
0x01
julia> x = UInt16(1)
0x0001
julia> parse(typeof(x), repr(x))
0x0001
ulia> x = Float64(1)
1.0
julia> parse(typeof(x), repr(x))
1.0
julia> x = Float32(1)
1.0f0
julia> parse(typeof(x), repr(x))
ERROR: ArgumentError: cannot parse "1.0f0" as Float32
Float16
also fails, but that doesn’t have a proper literal representation:
julia> x = Float16(1)
Float16(1.0)
julia> parse(typeof(x), repr(x))
ERROR: ArgumentError: cannot parse "Float16(1.0)" as Float16
Is this intentional?