Home > Back-end >  How this value judgement
How this value judgement

Time:10-23

Int a=1, b=2, c;
C=1.0/b * a

CodePudding user response:

0
1.0/b==0;
A==0 0 *;

CodePudding user response:

My sight is 0

CodePudding user response:

1.0/b==0;
Of course is 0.5

The
reference 1 floor? Victor.?? Response:
0
1.0/b==0;
A==0 0 *;

CodePudding user response:

The
reference 1 floor? Victor.?? Response:
0
1.0/b==0;
A==0 0 *;

The present should not b=0.5 1.0

CodePudding user response:

reference 4 floor qq_45464245 response:
Quote: refer to 1st floor? Victor.?? Response:
0
1.0/b==0;
A==0 0 *;

The present should not b=0.5 1.0

So int d=0.5; D how much??

CodePudding user response:

I think 1.0/b=0.5
C language, integer divided by the number of floating-point results are floating point Numbers,

When one of the divisor and dividend, as long as there is one) is a floating point number (or double), is a floating-point division, will take another divisor or dividend transformed into a higher precision for division (such as int to float, float into a double) results for floating point Numbers, only when the divisor and dividend is type int, shows the result of value is an integer,

CodePudding user response:

You use int define a, b, c;
In addition to the casts, otherwise how computing won't appear the decimal

CodePudding user response:

The
reference 1 floor? Victor.?? Response:
0
1.0/b==0;
A==0 0 *;

Do you have problems understanding.

1.0/b=1.0/2=0.500000
A=0.500000 * 0.500000 * 1=0.500000

Finally, c=0; Because c is integer data, thus integer 0.

CodePudding user response:

reference 4 floor qq_45464245 response:
Quote: refer to 1st floor? Victor.?? Response:
0
1.0/b==0;
A==0 0 *;

The present should not b=0.5 1.0

Don't forget to have type implicit ascending, 1.0/b will be calculated according to the division type double, 1.0/b * a; Will be in accordance with the type double data calculation

CodePudding user response:

refer to the eighth floor confident boy reply:
Quote: refer to 1st floor? Victor.?? Response:

0
1.0/b==0;
A==0 0 *;

Do you have problems understanding.

1.0/b=1.0/2=0.500000
A=0.500000 * 0.500000 * 1=0.500000

Finally, c=0; Because c is integer data, so will take the whole 0.

I'm sorry, I confused, operation first, then the int type conversion

CodePudding user response:

Calculated from left to right, 0
  • Related