如何在 Julia 中制作 Int8 文字?

How do I make an Int8 literal in Julia?

我可以在 Julia 中制作 "literals" 类型 Int64 甚至 Uint8

julia> typeof(8)
Int64

julia> typeof(0x08)
Uint8

但我一直没能找到如何制作 Int8 类型的文字。我尝试了一些不同的东西:

julia> 8::Int8
ERROR: type: typeassert: expected Int8, got Int64

julia> 0x08::Int8
ERROR: type: typeassert: expected Int8, got Uint8

julia> convert(Int8, 8)
8

julia> typeof(ans)
Int8

所以 convert 函数的应用起作用了,但这是一个有点罗嗦的表达。我想知道是否有更简洁的东西,比如 Rust 的 8i8。

我正在使用 Julia 0.3.3,但 Julia 0 的答案。4.x 也可以。

convert(Int8, 8) 更方便的是 Int8(8) 相应的 int8(8) 早期版本。像8i8这样的数字文字符号很少存在的原因是它与并列乘法冲突。

julia> i8=8
8

julia> 3i8
24