Pascal - 字符串到LongWord [英] Pascal - String to LongWord
本文介绍了Pascal - 字符串到LongWord的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的号码是字符串。
如何将该字符串转换为LongWord?
I have number as String. How to convert that string to LongWord?
我知道如何将其转换为整数。但是整数对我来说很小。
I know how to convert it to integer. But integer is to small for me.
推荐答案
实际上你可以使用StrToInt。
Actually you can use StrToInt.
结果值将溢出(即对于高于$ 7fffffff的值变为负值,您可能希望禁用溢出检查),但是当它被转换为longword时,您将获得正确的值。
The resulting value will overflow (i.e. become negative for values above $7fffffff, you might want to disable overflow checking), but when it is casted to longword, you will get the correct value.
虽然低位Val可能更安全:
Although the low level Val might be safer:
var
x: longword;
e: word;
begin
Val('$9fffffff', x, e);
writeln(x);
end.
这篇关于Pascal - 字符串到LongWord的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文