I have some float-pointing number (I don't know float is it, double or long double), and I want to convert It to the fraction. I look at the frexp
function, and I get mantissa and exponent of float-pointing type (FPT) number. I look at the struct numbers_limits<float, double or long double>
, and I get this fields: radix
(2), digits
(as I know, it is in the base radix), digits10
, max_digits10
. I think to conversion I must use max_digits10
, but I don't sure, and unfortunately my known of English do not let me understand which of this fields I must use to most accurate conversion. As I know, mantissa always have limited sum of bits, but in decimal base it is unlimited decimal fraction. Anyway, how many digits in decimal representation of mantissa I must use to most accurate conversion from FPT to fraction?
Or maybe I must find in mantissa a period, and convert it to fraction as a periodic decimal number?