Ada中的按位运算 [英] Bitwise Operations in Ada
问题描述
在某处有一个教程可以说明可以使用哪些数据类型按位运算吗?我不知道为什么艾达夫人认为我不能按位或两个Standard.Integer ...
Is there a tutorial somewhere that explains on which datatypes bitwise operations can be used? I don't know why Lady Ada thinks that I cannot bitwise OR two Standard.Integer...
$ gnatmake test.adb
gcc -c test.adb
test.adb:50:77: there is no applicable operator "Or" for type "Standard.Integer"
gnatmake: "test.adb" compilation error
真的吗?我为编译器无法与/或枚举数据类型感到抱歉。我为编译器无法对Character类型执行按位运算感到抱歉。我为编译器无法以我认为是显而易见的方式从Unsigned_8转换为Character而感到抱歉。但这是不可原谅的。
Really? I excused the compiler for not being able to AND/OR enumerated data types. I excused the compiler for not being able to perform bitwise operations on Character type. I excused the compiler for not being able to convert from Unsigned_8 to Character in what I thought was the obvious way. But this is inexcusable.
推荐答案
似乎没有人想出来回答这个该死的问题:
No one seems to want to just come out and answer the damn question:
Ada不对整数类型提供逻辑(按位)运算,而是在模块化类型。这是参考手册中的部分。
Ada doesn't provide logical (bit-wise) operations on integer types, it provides them on modular types. Here's the section in the reference manual.
这篇关于Ada中的按位运算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!