最近才发现Boolean原来是ByteBool解决方法
最近才发现Boolean原来是ByteBool
最近碰到一些问题,查了帮助才知道
A Boolean variable occupies one byte of memory, a ByteBool variable also occupies one byte, a WordBool variable occupies two bytes (one word), and a LongBool variable occupies four bytes (two words).
所以 Boolean(256)、Boolean(1024)等等都是False
真是杯具,写了好多代码都用if Boolean(I) then来判断大于0为True的
估计很多错误都不知道怎么办咯,。。
------解决方案--------------------
大于0就写 > 0 哎
------解决方案--------------------
觉着这么玩好玩啊
------解决方案--------------------
我想知道楼主为什么这么做?Boolean(256)、Boolean(1024)
------解决方案--------------------
很奇怪吗?
最近碰到一些问题,查了帮助才知道
A Boolean variable occupies one byte of memory, a ByteBool variable also occupies one byte, a WordBool variable occupies two bytes (one word), and a LongBool variable occupies four bytes (two words).
所以 Boolean(256)、Boolean(1024)等等都是False
真是杯具,写了好多代码都用if Boolean(I) then来判断大于0为True的
估计很多错误都不知道怎么办咯,。。
------解决方案--------------------
大于0就写 > 0 哎
------解决方案--------------------
觉着这么玩好玩啊
------解决方案--------------------
我想知道楼主为什么这么做?Boolean(256)、Boolean(1024)
------解决方案--------------------
很奇怪吗?
- Delphi(Pascal) code
TData = record case Byte of 0:(Int : Integer); 1:(bs:array [1..4]of Byte); 2:(bbb:Boolean); end; var Form1: TForm1; Data : TData; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin Data.int := 255;//bbb=true//bs[1]=255 Data.int := 256;//bbb=False//bs[1]=0 Tag := Data.Int; end;
------解决方案--------------------
汗一下楼主
------解决方案--------------------
写了好多代码都用if Boolean(I) then来判断大于0为True的
------------>
if BOOL(I) then 可以判断是否等于0,但是这个不区分符号的,只要不等于0都是True
------解决方案--------------------
别去折腾System
建议把Boolean改成函数(名称也改一下),批量替换一下。
------解决方案--------------------
小弟前来学习。