首页 文章

Julia:在BigFloat和BigInt中使用Underscore作为数字分隔符

提问于
浏览
0

根据朱莉娅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 的下划线用途还没有实现?

1 回答

  • 0

    此问题现已在Julia GitHub Issues网站here上发布和讨论 .

相关问题