Ask Your Question

Revision history [back]

You can count the number of digits before the decimal point by looking at the (ceiling of the) log in base 10 of your number:

sage: p = 2**372 * 3**239 - 1
sage: a = log(p,2)
sage: ceil(log(a.n(),10))
3

So, you just have to add this number to the digits paramter:

sage: a.numerical_approx(digits = 4+ceil(log(a.n(),10)))
750.8060

With another p:

sage: p = 2**3723 * 3**2394 - 1
sage: a = log(p,2)
sage: a.numerical_approx(digits = 4+ceil(log(a.n(),10)))
7517.4002