An integer holds 4 bytes. So you can code:
function Convert(const b0, b1, b2: Byte): Integer;
begin
Result :=b0 or (b1 shl 8) or (b2 shl 16);
end;
shl is shift-left, this keyword performs a bitwise shift left of an Integer. The number is shifted x bits to the left.
Example:
- Byte 0 = 1:
Code:
00000001
- Byte 1 = 2:
Code:
00000010
- Byte 2 = 5:
Code:
00000101
=> Result = 328,193
Code:
00000000-00000101-00000010-00000001
You can test by calc.exe of Windows.
function Convert(const b0, b1, b2: Byte): Integer;
begin
Result :=b0 or (b1 shl 8) or (b2 shl 16);
end;
shl is shift-left, this keyword performs a bitwise shift left of an Integer. The number is shifted x bits to the left.
Example:
- Byte 0 = 1:
Code:
00000001
- Byte 1 = 2:
Code:
00000010
- Byte 2 = 5:
Code:
00000101
=> Result = 328,193
Code:
00000000-00000101-00000010-00000001
You can test by calc.exe of Windows.