如何在Delphi7中定义一个无符号的64位整数? [英] How to define an unsigned 64-bit integer in Delphi7?

查看:1340
本文介绍了如何在Delphi7中定义一个无符号的64位整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Delphi 7中,int64s被签名,如果我尝试声明一个大于$ 8000000000000000的十六进制常量(例如,真正的一个uint64),我得到一个错误。你可以建议一些解决方法吗?

解决方案

你可以这样制作一个变体记录

  type muint64 = record 
case boolean of
true:(i64:int64);
false:(lo32,hi32:cardinal);
结束

现在,您可以使用红雀以无符号数据填充您的uint64。



另一个选项是使用这样的代码:

  const almostmaxint64 = $ 800000045000000; 
var muint64:int64;
begin
muint64:= almostmaxint64;
muint64:= muint64 shl 1;
end


In Delphi 7, int64s are signed, if I try to declare a hex constant larger than $8000000000000000 (eg, what is really an uint64) I get an error. Can you advise some workarounds, please?

解决方案

You can make a variant record like so

type muint64 = record
  case boolean of
    true: (i64 : int64);
    false:(lo32, hi32: cardinal);
end;

Now you can just use the cardinals to fill your uint64 with unsigned data.

The other option would be to use code like this:

const almostmaxint64 = $800000045000000; 
var muint64: int64;    
begin
   muint64:= almostmaxint64;
   muint64:= muint64 shl 1;
end

这篇关于如何在Delphi7中定义一个无符号的64位整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆