1 | initial version |
Since taking logarithms of large numbers is very slow, here's a faster way. First transform h
to a SageMath integer, then evaluate the parts of the logarithm individually:
hInt = ZZ(h)
exp = hInt.ndigits() - 1
char = int( hInt / 10^exp )
rem = hInt - char * 10^exp
print "h is {} x 10^{} + {}".format( char, exp, rem )
Here's a live example with just the calculation of P0
and h
.
2 | No.2 Revision |
Since taking logarithms of large numbers is very slow, here's a faster way. First transform h
to a SageMath integer, then evaluate the parts of the logarithm number individually:
hInt = ZZ(h)
exp = hInt.ndigits() - 1
char mult = int( hInt / 10^exp )
rem = hInt - char mult * 10^exp
print "h is {} x 10^{} + {}".format( char, mult, exp, rem )
Here's a live example with just the calculation of P0
and h
.