Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 15:07:32
Original
1345 people have browsed it

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)

#include <stdio.h>
#include <fenv.h>

int main()
{
	double x = 10;

	printf("x % 2 = %lf\n",x%2.0);

	return 0;
}</fenv.h></stdio.h>
Copy after login


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

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



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template