Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readdlm casts (un)signed integers to floats #8

Open
jakebolewski opened this issue Jun 10, 2016 · 1 comment
Open

readdlm casts (un)signed integers to floats #8

jakebolewski opened this issue Jun 10, 2016 · 1 comment
Labels

Comments

@jakebolewski
Copy link

jakebolewski commented Jun 10, 2016

julia> io = IOBuffer("0x0\n0x1\n0x2")
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=11, maxsize=Inf, ptr=1, mark=-1)

julia> readdlm(io)
3×1 Array{Float64,2}:
 0.0
 1.0
 2.0

julia> io = IOBuffer("0\n1\n2")
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=5, maxsize=Inf, ptr=1, mark=-1)

julia> readdlm(io)
3×1 Array{Float64,2}:
 0.0
 1.0
 2.0

julia> io = IOBuffer("foo\n1\n2")
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=7, maxsize=Inf, ptr=1, mark=-1)

julia> readdlm(io)
3×1 Array{Any,2}:
  "foo"
 1
 2

julia> io = IOBuffer("foo\n0x1\n0x2")
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=11, maxsize=Inf, ptr=1, mark=-1)

julia> readdlm(io)
3×1 Array{Any,2}:
  "foo"
 1
 2
@jakebolewski jakebolewski changed the title readdlm casts unsigned integers to floats readdlm casts (un)signed integers to floats Jun 10, 2016
@jakebolewski
Copy link
Author

jakebolewski commented Jun 10, 2016

This is also a problem when you try to parse integers that are larger than Int64:

julia> io = IOBuffer("1234532123456543212345675432134899348390483940")
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=46, maxsize=Inf, ptr=1, mark=-1)

julia> readdlm(io)
1×1 Array{Float64,2}:
 1.23453e45

julia> ans[1] == eval(parse("1234532123456543212345675432134899348390483940"))
false

@kshyatt kshyatt added the I/O label Jan 26, 2017
@ViralBShah ViralBShah transferred this issue from JuliaLang/julia Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants