Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - In KEIL c, division overflows.
In KEIL c, division overflows.
Well, in the compiler, in order to save the running time of the program, the calculation of constants is done by the compiler, and the result is given to the program without program calculation.

int a;

a = 10000/2/25;

When the program runs, A is 200 directly, and there is no calculation process of 10000/2/25.

Similarly,1200000/(32 *12 * 4800) is not calculated by the single chip microcomputer at runtime, but it is calculated by the compiler at compile time. Compiler calculation, based on the default data type. If your Keil is from a single chip microcomputer 5 1, then

And yours is a floating-point type, because it is necessary to add symbols to force the compiler to calculate according to floating-point numbers, and the modification is as follows:

AAA = 12000000.0 f/(32 * 12 * 4800);

Add an f after it, write a decimal point, and the compiler will calculate it as a floating point number.