What is the meaning of a dot (.) after an integer in c?

◇◆丶佛笑我妖孽 提交于 2021-02-02 09:26:24

问题


I would like to know if anybody knew what a . after an integer in C means.

i have this piece of code i want to convert and that is the only thing i am not sure of what it does.

if (y>=0.) what does the . here do?

full code:

double angleOf(double x, double y) {

  double  dist=sqrt(x*x+y*y) ;

  if (y>=0.) return acos( x/dist);
  else       return acos(-x/dist)+.5*CIRCLE_RADIANS; }

回答1:


It's same as 0.0, it will treat it as double instead of an integer, so you don't need to cast it.




回答2:


The trailing dot makes the literal a floating point (double) literal, instead of an integer one.



来源:https://stackoverflow.com/questions/14626715/what-is-the-meaning-of-a-dot-after-an-integer-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!