diff --git a/Project.toml b/Project.toml index 1ab3269..14532da 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,7 @@ name = "MatrixDepot" uuid = "b51810bb-c9f3-55da-ae3c-350fc1fbce05" -version = "1.0.14" + +version = "1.0.15" [deps] ChannelBuffers = "79a69506-cdd1-4876-b8e5-7af85e53af4f" @@ -15,8 +16,10 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [compat] ChannelBuffers = "0.3.1, 0.4" + DataFrames = "0.20 - 0.22, 1" MAT = "0.7 - 0.11" + Scratch = "1" julia = "1" diff --git a/src/matrixmarket.jl b/src/matrixmarket.jl index 381bfe1..44434e7 100644 --- a/src/matrixmarket.jl +++ b/src/matrixmarket.jl @@ -438,14 +438,18 @@ function parsenext(T::Type{<:AbstractFloat}, v::Vector{UInt8}, p1::Int) daccu += 10^df * iaccu end f = if di <= 16 && daccu < UInt(1)<<53 - if 0 <= eaccu < 23 + if eaccu == 0 + T(daccu) + elseif 0 < eaccu < 23 T(daccu) * exp10(eaccu) elseif 0 < -eaccu < 23 T(daccu) / exp10(-eaccu) else + sig = 1 parse(T, String(view(v, p1:i-1))) end else + sig = 1 parse(T, String(view(v, p1:i-1))) end i, (sig < 0 ? -f : f) diff --git a/test/common.jl b/test/common.jl index 4bf416f..b3555f3 100644 --- a/test/common.jl +++ b/test/common.jl @@ -206,3 +206,9 @@ io = IOBuffer() @test length(mdlist(hasdata(:A & (:b | :x)))) == 2 end + +# issue 131 +@testset "parse($str)" for str in ("-0.0010831521544791237\n", "-0.00108e100\n") + c = MatrixDepot.getbytes(IOBuffer(str)) + @test MatrixDepot.parsenext(Float64, c, 1)[2] == parse(Float64, str) +end