Numeric Limits For an AD and Base Types
Keywords: numeric limits ad base types syntax cppad::numeric_limits std::numeric_limits float epsilon min max quiet_nan example

| Prev | Next |  |  |  |  |  |  |

Numeric Limits For an AD and Base Types
Syntax
`eps = numeric_limits<Float>::epsilon()
` `min = numeric_limits<Float>::min()
` `max = numeric_limits<Float>::max()
` `nan = numeric_limits<Float>::quiet_NaN()
`
CppAD::numeric_limits
These functions and have the prototype `
static Float CppAD::numeric_limits<Float>::fun(void)
` where `fun` is `epsilon`, `min`, `max`, and `quiet_NaN`.
std::numeric_limits
CppAD does not use a specialization of `std::numeric_limits` because this would be to restrictive. The C++ standard specifies that Non-fundamental standard types, such as std::complex<double> shall not have specializations of `std::numeric_limits`; see Section 18.2 of ISO/IEC 14882:1998(E). In addition, since C++11, a only literal types can have a specialization of `std::numeric_limits`.
Float
These functions are defined for all `AD<Base>` , and for all corresponding `Base` types; see `Base` type base_limits .
epsilon
The result `eps` is equal to machine epsilon and has prototype `
Float eps
` The file num_limits.cpp tests the value `eps` by checking that the following are true `
1 != 1 + eps
1 == 1 + eps / 2
` where all the values, and calculations, are done with the precision corresponding to `Float` .
min
The result `min` is equal to the minimum positive normalized value and has prototype `
Float min
` The file num_limits.cpp tests the value `min` by checking that the following are true `
abs( ((min / 100) * 100) / min - 1 ) > 3 * eps
abs( ((min * 100) / 100) / min - 1 ) < 3 * eps
` where all the values, and calculations, are done with the precision corresponding to `Float` .
max
The result `max` is equal to the maximum finite value and has prototype `
Float max
` The file num_limits.cpp tests the value `max` by checking that the following are true `
abs( ((max * 100) / 100) / max - 1 ) > 3 * eps
abs( ((max / 100) * 100) / max - 1 ) < 3 * eps
` where all the values, and calculations, are done with the precision corresponding to `Float` .
quiet_NaN
The result `nan` is not a number and has prototype `
Float nan
` The file num_limits.cpp tests the value `nan` by checking that the following is true `
nan != nan
`
Example
The file num_limits.cpp contains an example and test of these functions.

Input File: cppad/local/numeric_limits.hpp