首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::fmax

Defined in header <cmath>

?

?

float fmax( float x, float y );

(1)

(since C++11)

double fmax( double x, double y );

(2)

(since C++11)

long double fmax( long double x, long double y );

(3)

(since C++11)

Promoted fmax( Arithmetic1 x, Arithmetic2 y );

(4)

(since C++11)

1-3%29返回两个浮点参数中较大的值,将nans视为nn与数值之间的丢失数据%28,则选择数值%29。

的所有参数组合的一组重载或函数模板算术类型不包括在1-3%29。如果有任何争论积分型,它被铸造成double.如果任何其他论点是long double,则返回类型为long double,否则就是double...

参数

x, y

-

values of floating-point or integral types

返回值

如果成功,则返回两个浮点值中较大的值。返回的值是准确的,不依赖于任何舍入模式。

错误处理

中指定的任何错误条件都不受此函数的影响。数学[医]错误处理...

如果实现支持ieee浮点算法%28IEC 60559%29,

  • 如果这两个参数之一是nan,则返回另一个参数的值。
  • 只有当这两个参数都是nan时,nan才会被返回。

注记

这个函数不需要对零的符号敏感,尽管一些实现还强制执行如果一个参数是+0而另一个参数是-0,则返回+0。

二次

代码语言:javascript
复制
#include <iostream>
#include <cmath>
 
int main()
{
    std::cout << "fmax(2,1)    = " << std::fmax(2,1) << '\n'
              << "fmax(-Inf,0) = " << std::fmax(-INFINITY,0) << '\n'
              << "fmax(NaN,-1) = " << std::fmax(NAN,-1) << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
fmax(2,1)    = 2
fmax(-Inf,0) = 0
fmax(NaN,-1) = -1

二次

另见

isgreater (C++11)

checks if the first floating-point argument is greater than the second (function)

fmin (C++11)

smaller of two floating point values (function)

max

returns the greater of the given values (function template)

max_element

returns the largest element in a range (function template)

minmax (C++11)

returns the smaller and larger of two elements (function template)

minmax_element (C++11)

returns the smallest and the largest elements in a range (function template)

c FMAX文档

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com