u64 位运算(v1.7.0-dev / spec v4.38)
English summary. Native
u64bitwise operators (& | ^ ~ << >>) in 1.5.0-dev/spec v4.36:<<wraps,>>is logical, shift counts clamp to[0,63], results print unsigned. Integer u64 only (float/bool/nil not enabled); mixing with non-literal signed stays TC9-loud; VM/AOT parity. See the English tooling index for the summary.
Q+ 1.5.0-dev 为 u64 增加原生位运算(VM 新 opcode 0x82–0x87):
& | ^ ~ << >>对 raw 64-bit 无符号值运算;<<为 wrap,>>为逻辑右移;- 移位计数 clamp [0,63](负数→0,>63→63);
- 结果打印为无符号十进制;
u64与非字面量 signed 混合运算 → TC9 loud;float/bool/nil 未放开;- VM/AOT 输出 parity(fixtures 覆盖,旧 TC20 断言迁移为 parity)。
示例:
fn main() -> i32 {
let a: u64 = 18446744073709551615
let b: u64 = 1085102592571150095
print(a & b); print(" "); print(a | b); print(" "); print(a ^ b)
return 0
}
注:当前实现对 hex 整数常量 > i64max 的 u64 标注字面量可能报 TC15;使用十进制全范围 字面量或 ≤ i64max 的 hex 值。该限制已记录在文档不一致清单中。
残余:旧 qbc 工具链需同步 bootstrap(v1.5.0 已刷新);其余整数字面量/转换语义见 spec §10/A.10。