Pascal - String to LongWord

为君一笑 提交于 2019-12-23 05:22:54

问题


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.


回答1:


Actually you can use StrToInt.

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.

Although the low level Val might be safer:

var
  x: longword;
  e: word;
begin
  Val('$9fffffff', x, e);

  writeln(x);
end.


来源:https://stackoverflow.com/questions/13142037/pascal-string-to-longword

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!