根据Julia 1.0.0 docs:
下划线_可用作数字分隔符:
julia> 10_000, 0.000_000_005, 0xdead_beef, 0b1011_0010
(10000, 5.0e-9, 0xdeadbeef, 0xb2)
但是,在Julia 1.0.0 REPL中,我得到了:
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
显然,下划线可以在BigInt
中使用,但不能在BigFloat
中使用。
这是设计上的还是仅在BigFloat
下划线使用了?