How to convert an integer to 3 hexadecimal bytes Delphi

Source: Internet
Author: User




How to convert an integer to 3 hexadecimal bytes Delphi
For example, the integer 149259 (all 6-bit data integer number) is converted to 16 into 2470B and then divided into three bytes 0B, to achieve code
Example
Var
Id:integer;
BYTEBUF:ARRAY[0..2] of Byte;
Begin
ID: = 149259;
..........
Bytebuf[0]: =//02
BYTEBUF[1]: =//47
BYTEBUF[2]: =//0b
End
------to solve the idea----------------------


Var

Id:integer;

BYTEBUF:ARRAY[0..2] of Byte;

Begin

ID: = 149259;

Move (id,bytebuf[0],3); The byte order will be the opposite of your request.

End


------to solve the idea----------------------
Var

Id:integer;

BYTEBUF:ARRAY[0..2] of Byte;

Begin

ID: = 149259;

Bytebuf[0]: = (ID and $FF 0000) SHR 16;

BYTEBUF[1]: = (ID and $00ff00) SHR 8;

BYTEBUF[2]: = ID and $0000ff;

End

How to convert an integer to 3 hexadecimal bytes Delphi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.