Calc Mode 0: Basics

Having seen it written on a blackboard in the Simpsons, I wanted to check if

398712 + 436512 = 447212

thus disproving Fermat’s Last Theorem. My pocket calculator confirmed the expression to be true, but those are big numbers, and the calculator lacks precision.

This seemed like a perfect opportunity to use calc mode.

M-x calc        to enter calc mode

First enter the left hand side

3987
<Enter>
12 ^
4365
<Enter>
12 ^

Both numbers are now there in the stack:

--- Emacs Calculator Mode ---
2:  16134474609751291283496491970515151715346481
1:  47842181739947321332739738982639336181640625

Hit + to add them together. Now to enter the right hand side.

4472
<Enter>
12 ^

Now the left and right sides of the original expression are there in the stack, and you can see that whilst they may be sufficiently equal to fool a pocket calculator, they can’t fool Emacs.

--- Emacs Calculator Mode ---
2:  63976656349698612616236230953154487896987106
1:  63976656348486725806862358322168575784124416

Hit  to see the difference:

1211886809373872630985912112862690

d g to group the number, then hit y to yank the number back into the current buffer.

1,211,886,809,373,872,630,985,912,112,862,690

… as I just did there.

See Also

Calc Mode 1: Binary Numbers

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.