C + + basic data type conversions

Source: Internet
Author: User

      • If either operand is a type long double, the other operand was converted to type long double.

      • If the above condition is not met and either operand are of type double, the other operand are converted to type double.

      • If the above-conditions is not met and either operand was of type float, the other operand was converted to Ty PE float.

If not floating-point precision

    1. If the above three conditions is not met (none of the operands is of floating types), then integral conversions is perf Ormed on the operands as follows:

      • If either operand is of type unsigned longand the other operand are converted to type unsigned long.

      • If the above condition is not met and either operand are of type long and the other of type unsigned int, Both operands is converted to type unsigned long.

      • If the above-the-conditions is not met, and either operand is of type long, the other operand was converted to Ty PE long.

      • If the above three conditions was not met, and either operand was of type unsigned int, the other operand is conve rted to type unsigned int.

      • If none of the above conditions is met, both operands is converted to type int.

          • Binary operations do not consider enumerations, and if both types are different and one side is floating-point type, both sides are converted to higher-level floating-point types. Otherwise both sides are integral promotion, and if the two types are different and the same is signed or unsigned, the lower-level type is converted to the high-level type. Otherwise, if the unsigned side level is above or equal to signed side, signed over there convert to unsigned yonder type. Otherwise if the signed side of the type can accommodate unsigned that side of the range, unsigned over there to convert to signed side of the type. Otherwise, both sides are converted to the unsigned type that corresponds to signed.

C + + basic data type conversions

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.