

Show HN: Calc – A fast and intuitive command-line calculator written in Go - alfredxing
https://github.com/alfredxing/calc

======
clarry
An alternative that isn't discussed in the _Why not use ...?_ section is calc:

[http://www.isthe.com/chongo/tech/comp/calc](http://www.isthe.com/chongo/tech/comp/calc)

It is very powerful, has history, shows previous calculations, and it's pretty
darn quick too.

Of course, there are plenty more calculators, powerful too. I only mention
calc because it bothers me that the name of this new project collides with it,
without really providing anything useful beyond having been written in a
fashionable language.

~~~
brute
Upvoted for calc. I use it for all the small calculation, as it most often
behaves slightly better than bc

    
    
      $ echo "1/2" | bc
      0
    
      $ echo "1/2" | bc -l
      .50000000000000000000
    
      $ echo "scale=1; 1/2" | bc
      .5
    
      $ echo "1/2" | calc -p
      0.5
    
      $ echo "+1+1+1+1" | bc -l
      (standard_in) 1: syntax error
    
      $ echo "+1+1+1+1" | calc -p
      4
    
      $ echo "sqrt(-1)" | bc -l
      Runtime error (func=(main), adr=4): Square root of a negative number
    
      $ echo "sqrt(-1)" | calc -p
      1i
    
      $ echo "s(pi)" | bc -l
      0
    
      $ echo "sin(pi())" | calc -p
      0

~~~
tartrate
Slightly shorter, and it's nice to have the expression at the end of the line:

    
    
        $ bc -l <<< "1+1"

------
soroushjp
Other comments are reasonable, but fantastic work alfredxing, played around
with it just now and loved how simple and intuitive it was. The only feature I
really miss here is being able to use the previous answer -- is this there and
I just didn't find it? Thinking of an 'ans' constant that holds the previous
answer

~~~
alfredxing
Thanks, and great suggestion! Would you mind opening an issue on GitHub for
it? I'll probably get around to implementing it soon.

~~~
soroushjp
Sorry HN doesn't have reply notifications and just saw this, just added the
issue!

------
qguv
I stopped using infix calculators a while back in favor of RPN/stack
calculators (dc) because I get quite tired of parens. Is the program
structured such that this change would be simple? Otherwise I feel like this
is simply yet another CLI calculator.

~~~
shiggerino
I use the M-x calc in Emacs for this reason.

~~~
agumonkey
I find emacs calc very fitting the RPN tradition (reminiscent of HP pocket
calculators), since it provides an algebraic solver; always a pleasurable
thing to witness.

------
commondream
Nice! I wrote one called maths a while back. It's in Ruby but I use it pretty
regularly and it does the trick:

[https://github.com/commondream/maths](https://github.com/commondream/maths)

------
brockrockman
Emacs natives should know "C-x * *". Worth learning the bin/hex support with
"d 2", "d 6".

------
Edmond
Also checkout [http://www.jasymchat.com](http://www.jasymchat.com), it is a
mobile version of Jasymca, A Java based computer algebra system.

------
otabdeveloper
Use Tab instead:
[http://bitbucket.org/tkatchev/tab](http://bitbucket.org/tkatchev/tab)

Includes a calculator, but also a complete declarative data-processing
language too.

E.g.:

    
    
        $ tab "[ log(@),@ : count(5) ]"  
        0	1
        0.693147	2
        1.09861	3
        1.38629	4
        1.60944	5

------
EmanueleAina
Qalculate has both a GUI and a command-line `qalc` util that does what `calc`
seems to do and much more:

[http://qalculate.sourceforge.net/](http://qalculate.sourceforge.net/)

------
EugeneOZ
Every small tool deserves special launching site and promoting if it's
"written in go" or some other hyped language.

~~~
redthrow
Most developers can't create something new and original or improve upon what's
best out there so they reinvent things with very limited functions with
something that people think is cool today (in this case, golang).

------
element11
Nice and great job ! I should switch to this. I have been using python until
now.

function calc { python -c "from math import *; print $1" }

~~~
tartrate
You might like
[https://github.com/Russell91/pythonpy](https://github.com/Russell91/pythonpy)
then.

------
v-yadli
I thought you mean calc.exe

------
redthrow
Why not use.. Scientific Calculator (PowerCalc) for Android?

[https://play.google.com/store/apps/details?id=com.scaleasw.p...](https://play.google.com/store/apps/details?id=com.scaleasw.powercalc)

~~~
mjcohen
My personal prejudice: I reject any calculator that does not compute the Gamma
function (or factorial of non-integer arguments). Therefore, I reject this
one.

