Julia: Using the Underscore as a Digit Separator in BigFloat and BigInt

0

According to the Julia 1.0.0 docs:

The underscore _ can be used as digit separator:

julia> 10_000, 0.000_000_005, 0xdead_beef, 0b1011_0010
(10000, 5.0e-9, 0xdeadbeef, 0xb2)

However, in the Julia 1.0.0 REPL I get this:

julia> VERSION
v"1.0.0"

# Underscore does not work work on right side of decimal in BigFloat.
julia> big"3.141_592"
ERROR: ArgumentError: invalid number format 3.141_592 for BigInt or BigFloat

 # Underscore does not work on left side of decimal in BigFloat.
julia> big"123_456.7898"
ERROR: ArgumentError: invalid number format 123_456.7898 for BigInt or BigFloat

# Underscore works for BigInt in example below:
julia> big"123_456_789"
123456789
julia> typeof(ans)
BigInt

Apparently, the underscore can be used in BigInt, but not BigFloat.

Is this by design or has underscore use for BigFloat simply not been implemented yet?

julia
asked on Stack Overflow Sep 23, 2018 by Julia Learner

1 Answer

0

This issue is now posted and discussed on the Julia GitHub Issues site here.

answered on Stack Overflow Sep 25, 2018 by Julia Learner

User contributions licensed under CC BY-SA 3.0