Pascal - String to LongWord

2019-06-13 07:14发布

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条回答
我欲成王,谁敢阻挡
2楼-- · 2019-06-13 08:05

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.
查看更多
登录 后发表回答