I have a small question. How come when I write this:
ComPrimSideCtr = (ComPrimSideCtr + 1) % 1.0E+6;
I get the error message: #31 expression must have integral type, but when I write:
ComPrimSideCtr = (ComPrimSideCtr + 1) % 1000000;
I don't get any error messages at all? Isn't 1.0E+6 the same number as 1000000?
Thanks in advance!
The e-notation (scientific notation) in C like this 1.0E+6
is used only for floating-point constants.
Since C doesn't allow floating point operands for %
operator, it emits that error message.
Isn't 1.0E+6 the same number as 1000000
No, 1.0E+6
is equivalent to 1000000.0
which is by default assumed as a double
constant (double precision floating point). While 1000000
is a integer ( int
) constant.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.