Julia 0.7
Why parse(UInt8 and parse(Int8 get diffrent type ?
julia> parse(UInt8,"255")
0xff
julia> parse(Int8,"127")
127
Paul
Julia 0.7
Why parse(UInt8 and parse(Int8 get diffrent type ?
julia> parse(UInt8,"255")
0xff
julia> parse(Int8,"127")
127
Paul
parse(UInt8, "255")
gives you a UInt8
while parse(Int8, "127")
gives you an Int8
. The first argument is to say what type you want to parse into.
Yes, but why two diffrent types of reasult : hex and dec ?
0xff
127
You mean why they print differently? Unsigned integers print like that.
This was dicussed in e.g. Change printing of Unsigned types to decimal base · Issue #30167 · JuliaLang/julia · GitHub.
In both samples like below I am expecting just 127 . Why are diffrent ?
julia> parse(Int8,"127")
127
julia> parse(UInt8,"127")
0x7f
Paul
In the original post, you gave two different values to convert from, 127 and 255.
You mean why they print differently? Unsigned integers print like that (in hexadecimal). It is the same number.
julia> parse(UInt8,"127")
0x7f
julia> Int(ans)
127