FixedPointDecimals.jl icon indicating copy to clipboard operation
FixedPointDecimals.jl copied to clipboard

Parse Int64 supports whitespace, parse FixedDecimal does not

Open mbravenboer opened this issue 4 years ago • 2 comments

Example:

julia> parse(Int64, "    5   ")
5

julia> parse(FixedDecimal{Int64,2}, "    5.0   ")
ERROR: ArgumentError: invalid digit: ' '

julia> parse(FixedDecimal{Int64,2}, "5.0")
FixedDecimal{Int64,2}(5.00)

julia> parse(Float64, "    3.14   ")
3.14

julia> parse(Float64, "    3 . 14   ")
ERROR: ArgumentError: cannot parse "    3 . 14   " as Float64

mbravenboer avatar May 19 '20 06:05 mbravenboer

That's interesting. I'd personally lean towards parse(Int64, ...) and parse(Float64, ...) not support whitespace

omus avatar May 22 '20 18:05 omus

Hmm, yeah i'm ambivalent. I guess accepting whitespace is also what C++'s parsing functions do as well (io >> x).

Given the julia behavior i'd say we should just do the same?

NHDaly avatar May 22 '20 23:05 NHDaly