8

I need to typeset the result of 88.6 to the 53rd power multiplied by 9216.

What I need is the full number, as part of a 6 page long equation of how long it would take to walk to the Andromeda Galaxy at 4 Mph. It should not be in scientific notation.

egreg
  • 1,121,712
  • That number has over 100 digits. Are you suggestion it should fit on a single line of text? – Werner May 27 '12 at 05:41
  • 2
    This doesn't seem to be a question about TeX, LaTeX or its friends. Perhaps math.stackexchange.com might be a better place to ask it? – bryn May 27 '12 at 05:47
  • Welcome to TeX.SE. I don't how else this is TeX related but to suggest $88.6^{53} \times 9216 = 1.508 \times 10^{107}$ – Peter Grill May 27 '12 at 05:47
  • Yes, I need it to because it is part of a 6 page long equation of how long it would take to walk to the Andromeda Galaxy at 4 Mph. It can not be in scientific notation. –  May 27 '12 at 05:48
  • Oh, I thought this would be the right place to ask this question. Sorry for wasting anybody's time. –  May 27 '12 at 05:51
  • @CameronJames Sometimes it is:) – yannisl May 27 '12 at 07:15
  • @CameronJames Me thinks you should modify the title to reflect the question better. – yannisl May 27 '12 at 07:17

2 Answers2

12

Unfortunately, bigintcalc allows computations only with integers. But in this case you know the number of digits in the integer part: the base 10 logarithm of 88.6^53 * 9216 is, approximately 107.178 and so we can perform the operation in integer arithmetic and adjust the result to have 108 digits in the integer part:

\documentclass{article}
\usepackage{xparse,l3str,bigintcalc}
\usepackage{numprint}

\npthousandsep{\hspace{.33333em plus .16667em minus .11111em}}
\npdecimalsign{.}

\ExplSyntaxOn
\NewDocumentCommand{\xnumprint}{mm}
 { % #1 = bigint expression, #2 = decimal places
  \tl_set:Nx \l_tmpa_tl { #1 }
  \tl_set:Nx \l_tmpb_tl { \str_substr:Nnn \l_tmpa_tl { #2 } { } }
  \tl_set:Nx \l_tmpa_tl { \str_substr:Nnn \l_tmpa_tl { } { #2 } }
  \use:x { \exp_not:N \numprint { \l_tmpa_tl.\l_tmpb_tl } }
 }
\ExplSyntaxOff
\begin{document}

\noindent\xnumprint{\bigintcalcMul{\bigintcalcPow{886}{53}}{9216}}{108}

\end{document}

enter image description here

egreg
  • 1,121,712
  • I'm confused why there are 2 answers to this problem that are very different numbers so I typed in the code: Z = IntegerRing() a = str(Z(886^53*9216)) into here [note that there are 2 lines-the second line starts with a=] and got egreg's answer. Can the other answer be correct? If not, why has it gotten so many points? – DJP May 27 '12 at 18:44
  • @DJP Yiannis's answer uses a wrong figure: 86^53. I checked with bc -l and the integral part is correct (I guess also the decimal part). – egreg May 27 '12 at 19:13
  • Thanks! I didn't notice the '8' was missing... – DJP May 27 '12 at 20:18
  • @DJP Oops! Didn't notice I typed the wrong digit either. Did it very quickly on the way to work in the morning. I guess it got upvoted as the question was standing on -4votes and closed and most people thought it couldn't be done using TeX. Here we try to upvote to encourage answers and reward effort. Personally I voted egreg's answer as well for his effort to get the decimal part right. – yannisl May 27 '12 at 21:28
  • That reminds me: +1 for both, and also the question. – DJP May 27 '12 at 21:51
8

Here is how:

\documentclass{article}
\usepackage{bigintcalc}
\begin{document}
\bigintcalcMul{\bigintcalcPow{86}{53}}{9216}
\end{document}

To format it:

\documentclass{article}
\usepackage{numprint}
\npthousandsep{ }
\usepackage{bigintcalc}
\begin{document}
\numprint{\bigintcalcMul{\bigintcalcPow{86}{53}}{9216}}
\end{document}

(Just a small error on the decimal).

enter image description here

You may also find this How to typeset large numbers, useful.

You might also like to place it in a parbox and add a phantom character to line up the thousands,

enter image description here

yannisl
  • 117,160