FixedPointDecimals.jl
FixedPointDecimals.jl copied to clipboard
Parse Int64 supports whitespace, parse FixedDecimal does not
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
That's interesting. I'd personally lean towards parse(Int64, ...)
and parse(Float64, ...)
not support whitespace
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?