我正在尝试将字符转换为Ada中的整数,似乎没有任何工作,我到目前为止能够从ASCII返回DEC但是我想返回0(整数)。
Character'Pos( '0');
返回48 - 我希望它返回0?
答案 0 :(得分:3)
您无法将字符直接转换为它们所代表的整数值,但可以使用字符串:
Some_Integer_Variable := Some_Integer_Type'Value ("0");
或者如果你有一个字符变量:
Some_Integer_Variable := Some_Integer_Type'Value ((1 => Character_Variable));