当前位置:Gxlcms > mysql > doublex=10,y=0;y=x%2;这个表达式正确吗?

doublex=10,y=0;y=x%2;这个表达式正确吗?

时间:2021-07-01 10:21:17 帮助过:98人阅读

The remainder function and % operator. 下面这段代码过不了编译的(gcc) #include stdio.h#include fenv.hint main(){double x = 10;printf(x % 2 = %lf\n,x%2.0);return 0;} operator % 仅能操作在整形数据中,(猜测,%的实现是根据数据位shift实现的). 这


The remainder function and % operator.


下面这段代码过不了编译的(gcc)

  1. #include <stdio.h>
  2. #include <fenv.h>
  3. int main()
  4. {
  5. double x = 10;
  6. printf("x % 2 = %lf\n",x%2.0);
  7. return 0;
  8. }</fenv.h></stdio.h>


operator % 仅能操作在整形数据中,(猜测,%的实现是根据数据位shift实现的).

这里浮点数的取余数调用 里面的fmod(doube x,double y)即可


人气教程排行