ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 11 Nov 2015 11:10:44 +0100Is there a more efficient way to compute the first digit of a number?https://ask.sagemath.org/question/30628/is-there-a-more-efficient-way-to-compute-the-first-digit-of-a-number/I need to compute the first digit of some large numbers. So far I've been converting them to strings, although it can be somewhat slow. For example:
sage: %timeit str(2^57885161)[0]
1 loops, best of 3: 3.07 s per loop
Is there a faster way to to do this? For my purpose you can assume that all the numbers involved are powers of some small base.A.P.Wed, 11 Nov 2015 11:10:44 +0100https://ask.sagemath.org/question/30628/