当我在浮点值上使用%运算符时,我得到错误,指出"二进制%的操作数无效(有'浮'和'双')".我只想输入整数值,但数字非常大(不在范围内) int类型)所以为了避免我使用float的不便.有没有办法在这么大的整数值上使用%运算符????
的%操作者只对整数型操作数所定义; 您需要将fmod*库函数用于浮点类型:
#include <math.h>
double fmod(double x, double y);
float fmodf(float x, float y);
long double fmodl(long double x, long double y);
Run Code Online (Sandbox Code Playgroud)