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.
Note also that bc allows defining functions (among other features), and is also arbitrary precision (factorial of 200 below):