1.double cannot use the remainder symbol%, floating-point number cannot be taken, such as 170%30.48 or 170.8%7 cannot be calculated
If you want to calculate, (1) multiply the corresponding multiples into shaping, take the remainder, then divide by the corresponding multiples, to double type
(2)
double Dorig = 15.01; int ntemp = (int) Dorig; int nresult = ntemp% 4; double Dresult = dorig-ntemp + nresult;
Similar methods
2. When using printf output, if the division operator / left and right floating point number, it can not be calculated, so there is no floating point in the printf Division operation
printf ("%d",30.48//// This does not work int d= 30.48;p rintf ("%d", D); // this will
3.
int i=/30.48; // At this point I have not output its value, so in this line of code, I equals 5.57 instead of 5printf ("%d", i); // at this point I output is 5
PTA 7.1 Summary
Some considerations for C-language operators/and%