News for hackers. Stuff that matters.
Re:Show HN: Calc, a simple command-line calulator in C by pwg on Tuesday June 09, 2015 @06:42AM (#9685019)
How is this different from the existing command-line calculator 'bc'?

    echo "3+4" | bc 
    7
Other than not needing equations to be piped to it?

Note also that bc allows defining functions (among other features), and is also arbitrary precision (factorial of 200 below):

    $ echo "define f (x) { if (x <= 1) return (1); return (f(x-1) * x); }; f(200)"| bc
    78865786736479050355236321393218506229513597768717326329474253324435\
    94499634033429203042840119846239041772121389196388302576427902426371\
    05061926624952829931113462857270763317237396988943922445621451664240\
    25403329186413122742829485327752424240757390324032125740557956866022\
    60319041703240623517008587961789222227896237038973747200000000000000\
    00000000000000000000000000000000000
Re:Show HN: Calc, a simple command-line calulator in C by creshal on Tuesday June 09, 2015 @07:14AM (#9685141)
Writing your own calculator is a nice programming exercise (touches a lot of different problems and is still a small, manageable task), especially for languages you're not familiar with. Of course there's better ones for "production" use.
Re:Show HN: Calc, a simple command-line calulator in C by vivekkannan on Tuesday June 09, 2015 @07:15AM (#9685143)
Obviously, bc is much more capable than calc. However, calc was not created to replace or even compete with bc or any other awesome command-line calculators. calc is my way of learning a bunch of stuffs (shunting yard).
Re:Show HN: Calc, a simple command-line calulator in C by nemoniac on Tuesday June 09, 2015 @07:20AM (#9685161)
First learning tip:

.h files are not the place for definitions.

Re:Show HN: Calc, a simple command-line calulator in C by vivekkannan on Tuesday June 09, 2015 @07:25AM (#9685181)
duly noted. will change it ASAP.
Re:Show HN: Calc, a simple command-line calulator in C by bstamour on Tuesday June 09, 2015 @11:55AM (#9686634)
You can use bc interactively just fine, no needing to pipe anything.

    $ bc
    3+4
    7
    ^D
    $
Re:Show HN: Calc, a simple command-line calulator in C by torrent-of-ions on Tuesday June 09, 2015 @11:17AM (#9686410)
This one doesn't have abitrary precision?
Re:Show HN: Calc, a simple command-line calulator in C by Dewie3 on Tuesday June 09, 2015 @08:17AM (#9685406)
That function syntax is a nice example of C-isms bleeding through. If I want to write some arithmetic, I want something more declarative and succinct than C.
Re:Show HN: Calc, a simple command-line calulator in C by murbard2 on Tuesday June 09, 2015 @10:18AM (#9686023)
Give the venerable dc a try. It can be quite succinct.

http://en.wikipedia.org/wiki/Dc_%28computer_program%29