
The Emacs Calculator (2009) - Pete_D
http://nullprogram.com/blog/2009/06/23/
======
knight17
Emacs calc can do financial/TVM calculations, too. A useful tutorial by Andrew
Hyatt on doing financial calculations [0]; he has wrote many other calc
tutorials [1] in the Emacs Google Plus community [2].

[0] Emacs financial calculations:
[https://plus.google.com/+AndrewHyatt/posts/YdwsbNmZ4NL](https://plus.google.com/+AndrewHyatt/posts/YdwsbNmZ4NL)

[1] Index of Andrew Hyatt's emacs calc tutorials:
[https://blog.markhepburn.com/2013/12/07/andrew-hyatts-
emacs-...](https://blog.markhepburn.com/2013/12/07/andrew-hyatts-emacs-calc-
tutorials)

[2] Emacs Google Plus community:
[https://plus.google.com/communities/114815898697665598016](https://plus.google.com/communities/114815898697665598016)

------
anyfoo
I took the time to properly learn and use emacs-calc this year, after being an
emacs user anyway. Before that, I tended to use bc on the shell for quick
calculations, but always felt that to be too limited.

Since then I am practically a daily user.

It's not without downsides, and some simple workflows that seem common and
trivial to me personally feel a bit awkward and contorting. For example,
working with variables/equations, with that '=>' "operator", is rather
strange. There also seems to be no support for hex numbers in 0x-prefixed
lowercase notation, which makes it hard to impossible to just copy and paste
hex numbers for programming. And while emacs-calc has a very impressive
scientific unit system, often I just want to use unit _prefixes_ , like u,m,M
for micro,milli,Mega respectively, without having to resort to using actual
physical units in my calculations (and then finding out again how to simplify
appropriately).

I also almost don't use the trail at all, mostly because its navigation and
actioning feels tedious and downright archaic, making me think that emacs-calc
probably started out a few decades ago, with a specific, now outdated,
terminal paradigm in mind.

But all in all, it's pretty impressive, and fills the role as my daily
companion for quick, and sometimes more elaborate, computations well.

~~~
imglorp
This small addition lets you work with SI byte units. I have no idea why this
wouldn't be in the default unit set, but hey, this is why we use emacs.

[https://raw.githubusercontent.com/mnp/dotfiles/master/shared...](https://raw.githubusercontent.com/mnp/dotfiles/master/shared-
elisp/my-calc-extras.el)

------
rsanders
Being an old HP48 user, finding Calc was what me fall the rest of the way in
love with Emacs. If I'm at the shell prompt I'll still startup GP/Pari for
quick calculations, but it's hard to beat Calc for longer sessions.

The only downside is that, like any advanced Emacs functionality, if you don't
use it frequently you forget all the commands.

~~~
lambda
And an HP48 emulator is still what I use on my phone as a calculator.

For the reason you mention, I need to get into the habit of using Calc for my
quick calculations; right now, I usually use Google (ick, infix notation) or
dc.

~~~
pasbesoin
I've have Free42 on my Android phone. Do you have a particular emulator to
recommend?

\--

[http://thomasokken.com/free42/](http://thomasokken.com/free42/)

~~~
lambda
I use Droid48:
[https://play.google.com/store/apps/details?id=org.ab.x48&hl=...](https://play.google.com/store/apps/details?id=org.ab.x48&hl=en)
([https://github.com/shagr4th/droid48](https://github.com/shagr4th/droid48))

~~~
pasbesoin
Thank you. I saw that one. Some of the more recent critical comments
(stability, responsiveness) gave me some pause.

I'll give it a go.

------
wiz21c
I love Emacs but the calculator, being stack based is just too awkward for me.
I know there is the "algebraic mode" but it still is too much. Is there a way
to configure it to work like, say, SpeedCrunch (my favorite calculator by far)
?

~~~
exikyut
TIL about SpeedCrunch!

[http://www.speedcrunch.org/](http://www.speedcrunch.org/)

[http://www.speedcrunch.org/download.html](http://www.speedcrunch.org/download.html)
even links to 32- and 64-bit prebuilt Qt binaries for Linux. Nice.

~~~
ihaveajob
How does it compare with good old command line 'mc'?

~~~
wiz21c
you mean "bc" ? Dunno, never used a lot.

For computations such as 10+3, it's comparabale. But I give SpeedCrunch an
dedge because it can compute "sin(pi/2)" out of the box.

~~~
ihaveajob
Yes, bc. Obviously it's been a while since I used it!

------
shoover
Calc is so useful to have right there. I have never used Windows calc since
discovering the emacs one many years ago. Once I got used to it I had to find
an RPN one for my phone (RealCalc and PCalc for Android and IOS,
respectively).

Algebraic formulas are great but beyond my typical reuse recall duration.

~~~
wiz21c
Could you explain why you feel RPN is better for you ? I've never been able to
get used to it... Maybe I get it wrong...

~~~
eadmund
After you get used to it, you end up being able to calculate much more
quickly. It's basically having a little Forth machine in your hand or at the
end of your keyboard.

~~~
macintux
The joy of never, ever having to type a parenthesis must be experienced to be
appreciated.

~~~
brians
And yet so many RPN people are Lisp programmers the rest of the time. I guess
it balances out.

~~~
thomastjeffery
I would really like a postfix lisp.

I wonder what edge cases I would run into designing one.

~~~
macintux
Aren't concatenative languages like Forth and Factor essentially what you're
looking for?

~~~
thomastjeffery
They are very focused on the stack, which isn't very lispy.

I was wondering how difficult it would be to make a common lisp or scheme, but
with postfix syntax instead of prefix.

~~~
kazinator
We could start by tinkering with a silly macro:

    
    
      [10]> (defmacro rev (&rest forms)
             `(progn ,@(mapcar (lambda (form)
                         (if (and (consp form) (rest form))
                           `(,(car (last form)) ,@(butlast form))
                           form))
                     forms)))
      REV
      [11]> (rev (1 1 +))
      2
      [12]> (rev (3 print) (1 1 +))
      3 
      2

------
jhallenworld
JOE also had a calculator: Esc M

It tries to include features of a Casio scientific calculator, so includes
things like statistics / regression (of selected block) and engineering
notation display. It inserts underscores between every three digits for easier
reading: 0.123_456

It is not reverse polish.

------
AlexCoventry
This totally nerd sniped me last night. But what is the point? I can't think
of a situation where it would give better results than professional tools
dedicated to the same tasks. It was probably cool in the 90s, when the
alternatives were much weaker.

------
zokier
I find the undogmatic approach to notations interesting here; the basic
calculator is RPN, but CAS/symbolic features ("expressions") use algebraic
notation (with separate "big" and normal notations). Of course everything has
elisp underpinnings with its prefix notation, which is also used for custom
extensions. Beyond those broad strokes, the basic notation used feels quite
quirky, like using _ for negatives

------
adrianmonk
"That's just awesome! That's a text editor ... doing calculus!"

Well, some might call that a good definition of scope creep, but at this point
I'm sure we're all well aware that even though Emacs might be called a text
editor, that's not really all it is.

~~~
xor-xor
I like to think of Emacs as a virtual lisp machine for writing _your own_ text
editor.

------
ne01
Here it goes again, my favorite OS, Emacs. If only it had a web browser as
good as chrome.

~~~
thomastjeffery
I wonder what a web browser would look like if it evolved inside emacs.

~~~
anyfoo
There were and still are approaches to web browsing in Emacs. But like every
other completely mainstream web browser, keeping up with the evolving web, and
especially its client-side programmability and performance needs, made its
usefulness rather marginal.

In the end it’s often less trouble to switch over to the browser window that’s
already open anyway and copy and paste data between it and emacs.

~~~
ne01
That's exactly the reason why I use Stumpwm as a wrapper for Emacs and
multiple chrome windows.

------
kickingvegas
Been using Emacs since '89 and did not know this was a thing. Thanks!

