I'm making some tests with float type (floating point number) with programming and in some of my tests I need to extract the fraction that originates the float value.
Let $ x $ be a floating point number, and $ a, b \in \mathbb{Z} $, where $ x \approxeq \frac{a}{b} $, I want to discover $ a $ and $ b $.
e.g., if I have $ 0.5 $, I need a method (maybe numerical?) that gives me $ \frac{1}{2} $ or some of its multiples.
If there's more than one method, I would like the fastest or simples to implement with a programming languagg.