double long float类型读入读出 double取模 fmod

Posted jzssuanfa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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!。!

!。!

!!!

!!

!!!!!


以上是关于double long float类型读入读出 double取模 fmod的主要内容,如果未能解决你的问题,请参考以下文章

java 变量数据类型转换?byte, short, char, int, long, float, double

C语言中 int float double char long short

20165223 week2学习查漏补缺

JAVA数据类型,变量,转换,常量,运算符

numeric 在Java中怎么定义,是啥类型的呢? float?还是double?还是long呢?

在java中的double和float类型数据相除为啥可以除以零