[英]Errors when dividing with floating point value in C
I want to take the the answer from x_rand / 0,2
and y_rand / 0,2
, and store the answer rounded down to an integer in the variable division_x
and division_y
: 我想借此从答案
x_rand / 0,2
和y_rand / 0,2
,并存储答案向下舍入变量整数division_x
和division_y
:
double x_rand = drand48();
double y_rand = drand48();
int division_x = x_rand / 0,2;
int division_y = y_rand / 0,2;
These are the error messages I get: 这些是我收到的错误消息:
breakout.c:95:37: error: expected identifier or '('
int division_x = x_rand / 0,2;
^
breakout.c:95:37: error: expected ';' at end of declaration
int division_x = x_rand / 0,2;
^
;
breakout.c:96:37: error: expected identifier or '('
int division_y = y_rand / 0,2;
^
breakout.c:96:37: error: expected ';' at end of declaration
int division_y = y_rand / 0,2;
^
;
breakout.c:95:33: error: division by zero is undefined
[-Werror,-Wdivision-by-zero]
int division_x = x_rand / 0,2;
^ ~
breakout.c:96:33: error: division by zero is undefined
[-Werror,-Wdivision-by-zero]
int division_y = y_rand / 0,2;
Someone please explain this to me. 有人请向我解释一下。
C does not use European style float representations. C不使用欧式浮点表示形式。 You need to use
0.2
, not 0,2
. 您需要使用
0.2
而不是0,2
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.