Quantcast
Channel: Delphi Forum - Delphi Programming Kings of Code - Delphi Programming
Viewing all articles
Browse latest Browse all 173

byte to integer converter

$
0
0
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.

Viewing all articles
Browse latest Browse all 173

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>