Function count_digits_same (o2scl)¶
-
template<class fp_t, class fp2_t>
int o2scl::count_digits_same(const fp_t &one, const fp2_t &two)¶ Count the number of digits which two floating point numbers share.
This function returns the number of digits which two floating point numbers share, even if they have different types. This function uses
static_cast
to convert the second number to the first type.If the two numbers are equal and at least one of the two numbers is non-zero, then this function returns
std::numeric_limits<fp_t>::max_digits10
. If both numbers are zero, then this function may returnnan
. This function may also fail if the numbers specified are nearly as small as the smallest representable number of the given type, in which case it returns -1. Thus this function returns eithernan
, or a number between -1 andstd::numeric_limits<fp_t>::max_digits10
.