首页 > 代码库 > double long float类型读入读出 double取模 fmod
double long float类型读入读出 double取模 fmod
The library of fmod is #include <cmath>
#include<cstdio> #include<cstdlib> #include<algorithm> #include<map> #include<cstring> #include<cmath> using namespace std; int main(){ double x; long y; long long z; scanf("%lf",&x); double doubleMod = fmod(x,(double)3); printf("The result of x mod 3 is %.2lf\n",doubleMod); scanf("%ld",&y); printf("The result of y is %ld\n", y); scanf("%lld", &z); printf("The result of z is %lld\n", z); return 0; }
cout << (-5) % 3 << endl; // 结果是-2!!!!!!!!!!!!!!!!!!!!!!!!
cout << fmod((double)(-5), (double)(-3))<<endl; //结果是-2!!!!!!!!!!!!!!!!
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。