Live data from Hacker News

Show HN: Calc – A fast and intuitive command-line calculator written in Go

github.com

1–10 of 34 posts

Re: Show HN: Calc – A fast and intuitive command-line calculator written in Go

#2
An alternative that isn't discussed in the Why not use ...? section is 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.

Re: Show HN: Calc – A fast and intuitive command-line calculator written in Go

#3
post #2

An alternative that isn't discussed in the Why not use ...? section is 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 hav…

Did 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`.

Re: Show HN: Calc – A fast and intuitive command-line calculator written in Go

#4
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.

Re: Show HN: Calc – A fast and intuitive command-line calculator written in Go

#5
post #4

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.

The 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?

Re: Show HN: Calc – A fast and intuitive command-line calculator written in Go

#6
post #4

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.

Obligatory XKCD: http://xkcd.com/645/

Re: Show HN: Calc – A fast and intuitive command-line calculator written in Go

#7
post #4

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.

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

Re: Show HN: Calc – A fast and intuitive command-line calculator written in Go

#10
post #2

An alternative that isn't discussed in the Why not use ...? section is 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 hav…

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
Post reply on HN