Hacker News new | ask | show | jobs
by knight17 2203 days ago
Since this is a calculator topic, I'd like request your input on which calculators you use.

I use the Emacs calculator (M-x calc) and XCalc (http://www.tordivel.no/xcalc/) as I like to use RPN calculators. The Windows 10 calculator is painful and slow. XCalc has a mini mode, where it will sit as a small, single line without distracting you too much. I like that feature very much.

One thing with Emacs is that I forget the shortcuts for non-frequent calculations that I'd have to go and search for it.

12 comments

My favorite calculator of all time is units(1). For example, to calculate how long it takes to download a 20 MiB file over a 56 kbit dialup connection:

  $ alias units='units --verbose' # in your shell rc
  $ units
  Currency exchange rates from FloatRates (USD base) on 2019-06-05
  3460 units, 109 prefixes, 109 nonlinear units
  
  You have: 56 kibibit/second
  You want: hour/20 mebibyte
          reciprocal conversion
          1 / (56 kibibit/second) = 0.8126984126984126977077949 hour/20 mebibyte
          1 / (56 kibibit/second) = (1 / 1.23046875) hour/20 mebibyte
Note that if you are on macOS, you want to install a more recent units via homebrew. The one shipping with the base system is positively ancient.
Python repl in a newly opened terminal session. Which is similar to the posted submission.

During grad school, I went through a period of trying many different GUI based calculators, until I realized what I really wanted was a language's repl.

One good thing about the Emacs calculator is the sheer number of features available. I don't use many, but occasionally use the financial functions, and they are really great. Any suggestions on programs out there with financial functions?

See Andrew Hyatt's Emacs calculator for Financial calculation tutorial: http://web.archive.org/web/20171218022230/https://plus.googl...

(Link rot, Google Plus, web.archive.org!)

I use insect almost daily ( https://github.com/sharkdp/insect ). It’s a command line calculator, not sure how well it would integrate with comint on emacs. Unit conversions built-in. I don’t know whether it has an RPN mode.

The other thing I do frequently is fire up a python3 repl for quick hits. I just did it yesterday for a complex mass file rename I couldn’t figure out how to do with shell variable replacement. With python it was easy with glob and os.rename.

I use a function "ev" that wraps bc. It's crude, but handy:

    $ ev() { echo "scale=3; $*" | bc -l; }
    
    $ ev 22/7
    3.142
I do something similar, with a couple of convenience substitutions for commas and multiplication:

$ math() { echo "scale=2 ; $" | sed -e "s:x::g" | sed -e "s:,::g" | bc; }

$ math 5,382 x 48,927.3

263326728.6

You should put this into a codeblock by indenting by 2 spaces. The formatting converts asterisk-delimited text into italics.

  $ math() { echo "scale=2 ; $*" | sed -e "s:x:*:g" | sed -e "s:,::g" | bc; }
  
  $ math 5,382 x 48,927.3
  
  263326728.6
I kid you not, I use Spotlight on macOS (cmd+space) as my simple calculator if I’m outside the terminal. If I’m inside the terminal I probably have an IPython instance open. For advanced stuff I use Mathematica as mentioned here: https://news.ycombinator.com/item?id=23428991
Not to mention, Spotlight does a /bunch/ of unit conversions. You can even type things like `1km/h to kt` for example. There's quite a few units defined already that I'm usually pleasantly surprised. This also works on iOS.

The one downside is you can't do unit conversions of a mathematical expression, just of a number. (i.e., 2^2 m/s does not work but 4 m/s does).

Whenever I have to do something more complicated I usually use M-x calc or maxima with ezunits.

As a RPN calculator user, my first choice is XCalc (http://www.tordivel.no/xcalc/).

The non-RPN one that I use the most is SpeedCrunch (http://speedcrunch.org/), Insect (https://github.com/sharkdp/insect/) and Frink (http://frinklang.org/). All have unit conversion too.

Frink is my tool of choice for computing, despite it bit esoteric.
I have all commands I don't remember bound to leader keys. When in calc I have [leader key] m and then which-key pops up everything I have stored.

Other than that, I use scratch in elisp mode and eval. Not as fluent as magnars, but this is a good example of what I mean (towards the end): https://youtu.be/jNa3axo40qM

Qalculate is the best desktop calculator I've used. It has a command line version, qalc.

Qalculate takes unit-aware calculation to the next level by including an algebraic solver. You don't have to rearrange everything to put your unknown on one side - you can just chuck 'x' into your equality somewhere and it'll work it out. For example, to verify the what-if xkcd assertion that an A10's main gun will propel Randall's car up to 7mph in 3 seconds:

(60/s) × (x s) × (395 grams) × (1010 m/s) = (3500 lbs)(70 mph) ≈ x = 2.0754319 s

2 seconds! Maybe Randall's car is heavier than 3500 lbs. How much heavier?

(60/s) × (3 s) × (395 grams) × (1010 m/s) = (x lb)(70 mph) ≈ x = 5059.1879

More like a Dodge Durango. Unless he's accounting for friction.

You see how nice it is to be able to swap around the unknowns in an equality. Other great features are a large number of built-in constants, an astounding variety of built-in functions - it's practically a CAS - and a command history, which is where I pulled the above example from. It also has a plugin for Plasma's krunner, so you can do quick calculations right there in the dropdown. To summarize: Qalculate is the shit.

Qalculate is great, but often I just use GNU bc. You just have to remember (or make some type of alias) to pass it the -l flag for floating point etc., and I also use -q for quiet. There's also dc(1) for RPN.
For an RPN calculator, I find orpie really great.

Otherwise I use WolframAlpha a lot.

For simple quick things I use ksh $((expressions)).