Exact value of a floating-point number as a rational
问题 I'm looking for a method to convert the exact value of a floating-point number to a rational quotient of two integers, i.e. a / b , where b is not larger than a specified maximum denominator b_max . If satisfying the condition b <= b_max is impossible, then the result falls back to the best approximation which still satisfies the condition. Hold on. There are a lot of questions/answers here about the best rational approximation of a truncated real number which is represented as a floating