Some considerations for C-language operators/and%

Source: Internet
Author: User

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%

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.