-Comparison Between 1l and 1u

Source: Internet
Author: User

-The 1l type is long int, And the 1u type is unsigned Int. For comparison, there is an implicit type conversion. In C, when a variable is long int, if the value range of long int can cover unsigned int, the variable of unsigned int is converted to long int; if the value range of long int cannot overwrite the unsigned int, the two variables are converted to unsigned long at the same time.

Assume that Int Is a 16-bit value, while long Int Is a 32-bit value. In this case, the value range of long int can cover the unsigned int, so 1u is converted to lont Int, -1l <1u.

In the current machine, int and long are generally 32-bit. In this case, the value range of long int cannot overwrite the unsigned Int, both variables are converted into unsigned long. After conversion, the value of-1l is 0 xffffffff. Then, the comparison result is-1l> 1u.

 

Reprinted from: http://blog.csdn.net/heziling/article/details/329499

-The 1l type is long int, And the 1u type is unsigned Int. For comparison, there is an implicit type conversion. In C, when a variable is long int, if the value range of long int can cover unsigned int, the variable of unsigned int is converted to long int; if the value range of long int cannot overwrite the unsigned int, the two variables are converted to unsigned long at the same time.

Assume that Int Is a 16-bit value, while long Int Is a 32-bit value. In this case, the value range of long int can cover the unsigned int, so 1u is converted to lont Int, -1l <1u.

In the current machine, int and long are generally 32-bit. In this case, the value range of long int cannot overwrite the unsigned Int, both variables are converted into unsigned long. After conversion, the value of-1l is 0 xffffffff. Then, the comparison result is-1l> 1u.

 

Reprinted from: http://blog.csdn.net/heziling/article/details/329499

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.