JuliaMath/Decimals.jl

parse underscores

gdkrmr opened this issue · 2 comments

Underscores are not parsed correctly:

julia> decimal("10_000")
ERROR: ArgumentError: invalid BigInt: "10_000"
Stacktrace:
 [1] macro expansion at ./gcutils.jl:87 [inlined]
 [2] tryparse_internal(::Type{BigInt}, ::String, ::Int64, ::Int64, ::Int64, ::Bool) at ./gmp.jl:257
 [3] #parse#333(::Nothing, ::Function, ::Type{BigInt}, ::String) at ./parse.jl:225
 [4] parse at ./parse.jl:225 [inlined]
 [5] parameters at /home/gkraemer/.julia/packages/Decimals/GlFbH/src/decimal.jl:22 [inlined]
 [6] parse(::Type{Decimal}, ::String) at /home/gkraemer/.julia/packages/Decimals/GlFbH/src/decimal.jl:6
 [7] decimal(::String) at /home/gkraemer/.julia/packages/Decimals/GlFbH/src/decimal.jl:10
 [8] top-level scope at none:0

julia> big"10_000"
10000

@gdkrmr Hm, how are underscores supposed to be processed? I haven't seen underscores used in numbers before.

You can use underscores in numbers for better readability

julia> i = 1_000
1000