How to use fmax() function get smaller of two floating point arguments in C++

1 Answer

0 votes
using namespace std;

int main()
{
	cout << "fmin(10.0, 1.0) = " << fmin(10.0, 1.0) << endl;
	cout << "fmin(-10.0, 1.0) = " << fmin(-10.0, 1.0) << endl;
	cout << "fmin(-10.0, -1.0) = " << fmin(-10.0, -1.0) << endl;
	cout << "fmin(-INFINITY, 0) = " << fmin(-INFINITY, 0) << endl;
	cout << "fmin(NAN, -1) = " << fmin(NAN, -1) << endl;

	return 0;
}

/*
run:

fmin(10.0, 1.0) = 1
fmin(-10.0, 1.0) = -10
fmin(-10.0, -1.0) = -10
fmin(-INFINITY, 0) = -inf
fmin(NAN, -1) = -1

*/

 



answered Mar 17, 2016 by avibootz
...