Then the value of expression x = 1 y = x + 3/2 is 2.0 C language: If the X and Y types are defined as double

Source: Internet
Author: User
The result of 2.3/2 is that when the value of 1 of int is assigned to the X of double, it is automatically upgraded to the value of double type. 1 is of the int type.

|
It seems that the results of float and double calculation will contain. 0. If int, there will be no such results.

|
If it is defined as int type (integer), the value of the defined integer is 2 double type (floating point type) yes. The defined y value of the defined real number can only be of the 2.0doudle type. The defined range is larger than that of the int type.

1. X = 1 first, increase the 1 of int to 1.0 of double, and then the X of double plus the 1 of int, so x = 1.0 (note that 1.0 is of the double type) then x + 1.0 = 2.0 (2.0 is double type)

Related Article

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.