无法在Julia中声明数字类型

时间:2015-09-18 17:38:38

标签: julia

根据http://julia.readthedocs.org/en/latest/manual/integers-and-floating-point-numbers/,应该能够做到这一点:

julia> Float32(-1.5)
-1.5f0

相反,我得到:

julia> Float32(-1.5)
ERROR: type cannot be constructed

对于使用此语法的所有其他尝试都会发生这种情况,例如: x = Int16(1)

我在0.3.10。

1 个答案:

答案 0 :(得分:4)

你在0.3.10,但阅读手册0.5。在0.3 http://julia.readthedocs.org/en/release-0.3/manual/integers-and-floating-point-numbers/

的手册中
Values can be converted to Float32 easily:

julia> float32(-1.5)
-1.5f0

julia> typeof(ans)
Float32
相关问题