This question already has an answer here:

When I run

Rationalize[2.98688387095, 0]

I get $\frac{117300079}{39271724}$

However, when I run

N[117300079/39271724, 50]

I get


But what I really wanted was


How can I find the exact rational form of 2.98688387095?


marked as duplicate by Carl Woll, m_goldberg, Coolwater, Henrik Schumacher, J. M. will be back soon Apr 13 '18 at 7:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ Per the linked question, you could try FromDigits @ RealDigits @ 2.98688387095. $\endgroup$ – Carl Woll Apr 13 '18 at 1:43
  • 1
    $\begingroup$ As I explain in my answer to the question linked by Carl, Rationalize[num, 0] doesn't give an exact rational conversion. You instead need Rationalize[num`z,0], where (simplifying from my answer) z>= twice the number of digits in the number. So, for your case, using a z of 100 (far more than enough), we have: x = Rationalize[2.98688387095`100, 0] and N[x, 50] = 2.9868838709500000000.... $\endgroup$ – theorist Apr 13 '18 at 7:01