TRecord = record
8 个 Boolean
end; 和
TRecord2 = record
8 个 Byte;
end;占用的内存一样大?我想给 8 个 Boolean 分配 一个Byte的内存 该怎么弄我目前的想法很弱智 就是 定义一个 Byte 然后 把Byte位移操作 得到 8 个Boolean
不过这样效率不就很低了应该有好点的办法吧
不然 这个boolean 就没什么意义了
解决方案 »
- 请教,如何让richedit的行高等于该行字体的实际高度?
- 如何将RichEdit中输入的文本转成BMP图片
- 大伙来说说delphi都用什么来制做的安装程序!
- 从来没散过分,今天高兴,送100分求一份学籍管理系统的源码,谢谢!
- 关于DBCombobox的问题,大鸟们,帮帮忙!
- 关于IC卡门锁接口的开发
- 如何判断一数组中a: array[1..10] of string没有重复值。
- 有人用Delphi2007做过绿色软件吗?
- 如何注销或退出WIN2000系统,用哪些函数
- 呵呵,问一个很菜的问题:ToolButton上面的图标怎么加上去哟?
- 调用dll里的函数问题
- 怎么用delphi来执行这句命令,Rundll32.exe CameraDll.dll,CameraSubArea?
ByteBool-1 byte
WordBool-2 bytes
LongBool-4 bytes你是想用一个byte的每一位表示1个boolean,即8个boolean值?
如果是,你的方法也是可行,效率不会低,还可以用与操作。
boolean1: = (byteValue and 1=1)
boolean2: = (byte and 2=2)
boolean3: = (byteValue and 4=4)
boolean4: = (byteValue and 8=8)
boolean5: = (byteValue and 16=16)
boolean6: = (byteValue and 32=32)
boolean7: = (byteValue and 64=64)
boolean8: = (byteValue and 128=128)
菜菜的再确定下boolean1: = (byteValue and 1=1)
boolean2: = (byte and 2=2)
boolean3: = (byteValue and 4=4)
boolean4: = (byteValue and 8=8)
boolean5: = (byteValue and 16=16)
boolean6: = (byteValue and 32=32)
boolean7: = (byteValue and 64=64)
boolean8: = (byteValue and 128=128)
是单独的?
begin
Result := Value and (1 shl Bit) <> 0;
end;
begin
Result := Value and (1 shl Bit) <> 0;
end;
8 个 Boolean
end; 和
TRecord2 = packed record
8 个 Byte;
end;
function GetBool (SByte: Byte; Bit: Byte): Boolean;
begin
Result := (SByte and (1 shl Bit)) <> 0;
end;function SetTrue (SByte: Byte; Bit: Byte): Integer;
begin
Result := SByte or (1 shl Bit);
end;function SetFalse (SByte: Byte; Bit: Byte): Integer;
begin
Result := SByte and not (1 shl Bit);
end;结帖