Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.
///// 1. from BitWise unit, to manipulate bits:
function IsBitSet(const val: longint; const TheBit: byte): boolean;
begin
result := (val and (1 shl TheBit)) <> 0;
end;
function BitOn(const val: longint; const TheBit: byte): LongInt;
begin
result := val or (1 shl TheBit);
end;
function BitOff(const val: longint; const TheBit: byte): LongInt;
begin
result := val and ((1 shl TheBit) xor $FFFFFFFF);
end;
function BitToggle(const val: longint; const TheBit: byte): LongInt;
begin
result := val xor (1 shl TheBit);
end;
///// 2. My SetBit and GetBit:
procedure SetBit(var vValues:array of byte;vBit:integer);
var vPos,vBitPos:integer;
begin
If vBit = 0 Then // for first bit! or we get -1 from Ceil(vBit/8)-1
vPos:=0
else
vPos:=Ceil(vBit/8)-1; // which byte
vBitPos:=vBit mod 8; // which bit in byte
// set the bit
vValues[vPos]:=BitOn(vValues[vPos],vBitPos);
end;
function GetBit(vValues:array of byte; vBit:integer):integer;
var vPos,vBitPos:integer;
begin
If vBit = 0 Then // for first bit! or we get -1 from Ceil(vBit/8)-1
vPos:=0
else
vPos:=Ceil(vBit/8)-1; // which byte
vBitPos:=vBit mod 8; // which bit in byte
// read if bit is set or not
If IsBitSet(vValues[vPos],vBitPos) Then
Result:=1
else
Result:=0;
end;
///// 3. Usage
procedure TForm1.Button2Click(Sender: TObject);
type TRec = record
vId:integer;
vBytes:array of byte;
end;
var
i,j: Integer;
vStr:string;
vArray:array of TRec;
k: Integer;
begin
// set array 3x3
SetLength(vArray,3);
SetLength(vArray[0].vBytes,3);
SetLength(vArray[1].vBytes,3);
SetLength(vArray[2].vBytes,3);
// set 3 bits
SetBit(vArray[0].vBytes,0);
SetBit(vArray[1].vBytes,11);
SetBit(vArray[2].vBytes,23);
// read same 3 bits
ShowMessage('bit 0 = '+IntToStr(GetBit(vArray[0].vBytes,0)));
ShowMessage('bit 11 = '+IntToStr(GetBit(vArray[1].vBytes,11)));
ShowMessage('bit 23 = '+IntToStr(GetBit(vArray[2].vBytes,23)));
// write 3x3 bytes to memo, to see 'binary' results
vStr:='';
for i := 0 to Length(vArray) - 1 do
begin
vStr:='';
for k := 0 to Length(vArray[i].vBytes) - 1 do
for j := 0 to 7 do
begin
if IsBitSet(vArray[i].vBytes[k],j) then
vStr:='1'+vStr
else
vStr:='0'+vStr;
end;
Memo1.Lines.Add(vStr);
end;
end;
type TBit = (Bit0, Bit1, Bit2, Bit3, Bit4, Bit5, Bit6, Bit7);
TBits = set of TBit;
var Bits: TBits;
B: byte;
begin
Bits := [Bit0, Bit3];
B := Byte(Bits); // B is now 9
B := 129;
Bits := TBits(B); // Bits is now [Bit0, Bit7]
if (Bit0 in Bits) then
begin
// check for a signle bit
end;
end;
But I think the better question for you is to find out why you are using so much memory. Mostly it means a design flaw.
Can you explain why you need so much memory?