Understanding of loword, hiword, lobyte, and hibyte

Source: Internet
Author: User

Loword () gets a 32-bit low 16-bit
Hiword () to get a 32-bit high 16-bit
Lobyte () gets the byte with the lowest 16 bits (rightmost)
Hibyte () gets the byte with the highest 16 bits (leftmost)

Loword and hiword are frequently used in the past. For example, the Message Parameter lparam stores the mouse position. lparam is 4 bytes. It stores X at the lower two and Y at the higher two. however, I have never understood lobyte or hibyte.

When lobyte and hibyte are applied to the number of 32 bits, they should be used in the last 16 bits of the number of 32 bits.

# Include <iostream> # include <windows. h> int main () {// I = 10241035 (0x009c440b) int I = 10241035; Word ih = hiword (I ); // take 16-bit high word IL = loword (I); // take 16-bit low // result: 9 CSTD: cout <STD :: hex <"I high:" <IH <STD: Endl; // result: 440 bstd: cout <STD :: hex <"I low position:" <IL <STD: Endl; Word bH = hibyte (I ); // obtain the high 8-bit word BL = lobyte (I); // take the low 8-bit word BL = lobyte (I); // result: 44 (Yes 44, not 0, I have always understood the error) STD :: cout <STD: Hex <"I high:" <BH <STD: Endl; // result: bstd: cout <STD :: hex <"I low position:" <BL <STD: Endl; return exit_success ;}

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.