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

float conversion fails on certain substrings #9781

Closed
mrtzh opened this issue Jan 15, 2015 · 6 comments
Closed

float conversion fails on certain substrings #9781

mrtzh opened this issue Jan 15, 2015 · 6 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@mrtzh
Copy link

mrtzh commented Jan 15, 2015

Converting SubString to Float64 using float fails on some valid inputs:

julia> float(split("0,1\n",",")[2])
ERROR: ArgumentError("float64(String): invalid number format")
 in float64 at string.jl:1594
 in float at string.jl:1607

In contrast to:

julia> float("1\n")
1.0
julia> split("0,1\n",",")[2]
"1\n"
@IainNZ
Copy link
Member

IainNZ commented Jan 15, 2015

Problem seems to be here:

julia/base/string.jl

Lines 1601 to 1602 in 3f4be47

float64_isvalid(s::SubString, out::Array{Float64,1}) =
ccall(:jl_substrtod, Int32, (Ptr{UInt8},Csize_t,Cint,Ptr{Float64}), s.string, s.offset, s.endof, out) == 0

this returns false

@IainNZ IainNZ self-assigned this Jan 15, 2015
@IainNZ IainNZ added the bug Indicates an unexpected problem or unintended behavior label Jan 15, 2015
@vtjnash
Copy link
Member

vtjnash commented Jan 15, 2015

cross-link #9487

@IainNZ
Copy link
Member

IainNZ commented Jan 15, 2015

I believe fixed by #9783

@mrtzh
Copy link
Author

mrtzh commented May 8, 2015

BTW, I still have this problem on julia 0.3.7 (Ubuntu).

@pao
Copy link
Member

pao commented May 8, 2015

@mrtzh, the fix wasn't backported to the 0.3 branch; I've asked in that bug if it's a good candidate. Thanks!

@pao
Copy link
Member

pao commented May 9, 2015

@mrtzh, the fix has been backported to the release-0.3 branch. If you can build Julia, you can test that now and let us know if it's fixed for you; otherwise, barring any problems it should be available in Julia 0.3.9. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

5 participants