11 ms·
Show HN: Calc – A fast and intuitive command-line calculator written in Go
- clarry 12y agoAn 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.
- alfredxing 12y agoDid not know about this. It looks great, I'll definitely be trying it out! The project name was originally calc.go, but as you can imagine that didn't work out too well with `go get`.
- brute 12y agoUpvoted 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 12y agoSlightly shorter, and it's nice to have the expression at the end of the line: $ bc -l <<< "1+1"
- mackal 12y agoI've been using wcalc personally, haven't had many reasons to use something else.
- donpdonp 12y agowcalc is pretty much the best terminal-mode calculator anywhere. It handles significant digits very well and knows about a bunch of mathematical constants in unicode form! -> √7×2÷π−ε0×σ+α+γ+R∞×Mτ-Φ0 = 2.26885 http://w-calc.sourceforge.net/download.php http://w-calc.sourceforge.net/download.php
- voltagex_ 12y agoand it's apt-gettable from wheezy upwards!
- chanux 12y agoThanks for bringing the original(?) calc to light. without really providing anything useful beyond having been written in a fashionable language The latter part of your comment sounds a bit discouraging. I think the developer didn't mean any harm an probably didn't know about this one. PS: The dev had replied in the thread. All is well I guess.
- chanux 12y agocalc package is called apcalc on dbian/ubuntu.
- hobarrera 12y agoThis developer could have at least chosen a different name. Two programs, same funcionality, same name. Haven't we learnt anything?
- alfredxing 12y agoAs I mentioned below, I chose "calc.go", but that didn't work well with the `go get` command, so I had to get rid of the ".go"
- qguv 12y agoI 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.
- alfredxing 12y agoThe algorithm I use combines shunting-yard and postfix (RPN) evaluation, but I guess it wouldn't be too hard to modify the source to just do the RPN part. If you want to try that, the relevant code is the Evaluate function in `compute/compute.go`. A Google search for "command line calculator" doesn't turn up much, so I honestly didn't think there were many decent ones out there (aside from dc/bc). Are there any you have in mind?
- alfredxing 12y agoObligatory XKCD: http://xkcd.com/645/ http://xkcd.com/645/
- shiggerino 12y agoI use the M-x calc in Emacs for this reason.
- agumonkey 12y agoI 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.
- bernalex 12y agoIncidentally I wrote a simple CLI RPN calc in half an hour recently: https://github.com/alexander-b/clac https://github.com/alexander-b/clac I was planning on adding a REPL-mode to it today for fun, and then someone linked me this post, saying "this could have been clac!", hehe.
- ConceptJunkie 12y agoPeople interested in this calculator might be interested in my project, which is written in Python: https://github.com/ConceptJunkie/rpn https://github.com/ConceptJunkie/rpn My rpn calculator started out comparable to the project described here, once I discovered the mpmath library, the project took on a life of its own and now has over 400 operations covering basic math, number theory, combinatorics, unit conversions (comparable to the GNU units program, or the Frink programming language), algebra and anything else that strikes my fancy.
- Edmond 12y agoAlso checkout http://www.jasymchat.com http://www.jasymchat.com, it is a mobile version of Jasymca, A Java based computer algebra system.
- brockrockman 12y agoEmacs natives should know "C-x * *". Worth learning the bin/hex support with "d 2", "d 6".
- EmanueleAina 12y agoQalculate 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/
- soroushjp 12y agoOther 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 12y agoThanks, and great suggestion! Would you mind opening an issue on GitHub for it? I'll probably get around to implementing it soon.
- soroushjp 12y agoSorry HN doesn't have reply notifications and just saw this, just added the issue!
- element11 12y agoNice 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 12y agoYou might like https://github.com/Russell91/pythonpy https://github.com/Russell91/pythonpy then.
- commondream 12y agoNice! 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
- redthrow 12y agoWhy not use.. Scientific Calculator (PowerCalc) for Android? https://play.google.com/store/apps/details?id=com.scaleasw.powercalc https://play.google.com/store/apps/details?id=com.scaleasw.p...
- mjcohen 12y agoMy personal prejudice: I reject any calculator that does not compute the Gamma function (or factorial of non-integer arguments). Therefore, I reject this one.
- otabdeveloper 12y agoUse 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
- EugeneOZ 12y agoEvery small tool deserves special launching site and promoting if it's "written in go" or some other hyped language.
- redthrow 12y agoMost 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).
- v-yadli 12y agoI thought you mean calc.exe