isgreaterequal()函数确定第一个参数的值是大于还是等于第二个参数的值。如果第一个参数大于或等于第二个参数,则返回1,否则返回0。
考虑两个数字“ x”和“ y”。语法为:
bool isgreaterequal(float x, float y); bool isgreaterequal(double x, double y); bool isgreaterequal(long double x, long double y); bool isgreaterequal(Arithmetic x, Arithmetic y);
(x,y):我们要比较的值。
参数 | 返回值 |
---|---|
x>=y | 1 |
x | 0 |
让我们看一个简单的示例,其中x和y都是相同的类型。
#include <iostream> #include<math.h> using namespace std; int main() { double x=8.7; double y=7.7; cout<<"Values of x and y are : "<<x<<","<<y<<'\n'; cout<<"isgreaterequal(x,y) : "<<isgreaterequal(x,y); return 0; }
输出:
Values of x and y are: 8.7,7.7 isgreaterequal(x,y) :1
在此示例中,isgreaterequal()函数确定x的值大于y。因此,它返回1。
让我们看一个简单的示例,其中x和y都是不同的类型。
#include <iostream> #include<math.h> using namespace std; int main() { double x=8.7; int y=7; cout<<"Values of x and y are : "<<x<<","<<y<<'\n'; cout<<"isgreaterequal(x,y) : "<<isgreaterequal(x,y); return 0; }
输出:
Values of x and y are : 8.7,7 isgreaterequal(x,y) : 1
在此示例中,isgreaterequal()函数确定x的值大于y。因此,它返回1。
让我们看一个简单的例子,当x的值为nan时。
#include <iostream> #include<math.h> using namespace std; int main() { double x=0.0/0.0; double y=8.0; cout<<"Values of x and y are : "<<x<<","<<y<<'\n'; cout<<"isgreaterequal(x,y) : "<<isgreaterequal(x,y); return 0; }
输出:
Values of x and y are : nan,8.0 isgreaterequal(x,y) : 0
在此的示例x的值为NAN。因此,该函数返回0。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)