Node:Get Second Largest Real, Previous:Register Width, Up:System Information



Get Second Largest Real

template <class Real> Real get_second_largest (Real MAX_VAL, [bool verbose = false]) Template function
float get_second_largest (float, bool) Template specialization
double get_second_largest (double, bool) Template specialization
get_second_largest returns the second largest floating point number of the type specified the template paramater Real. If verbose is true, messages are printed to standard output.

This function is used for setting the value of MAX_REAL. See Global Constants and Variables.

get_second_largest depends on there being an unsigned integer type with the same length as Real. This should always be the case for float and double, but may not be long double.

MAX_VAL should be the largest number of type Real on a given architecture. The GNU C++ compiler GCC 3.3 does not currently supply the numeric_limits template, so it is necessary to pass one of the macros FLT_MAX or DBL_MAX explicitly, depending on which specialization you use1. When and if GCC supplies the numeric_limits template, I will eliminate the MAX_REAL argument.


Footnotes

  1. If your system supplies an unsigned integer type with the same length as long double, then you can instantiate get_second_largest<long double>() and call get_second_largest<long double>(LDBL_MAX). However, I doubt that this amount of precision would be worthwhile. If it ever were required, 3DLDF would have to be changed in other ways, too. In particular, it would have to use more precise trigonometric functions for rotations. See Accuracy.