You are not logged in.
Hello,
I've been trying out bc today and I've come across something:
If, for example, I try and calculate 1/10 in bc (whilst setting scale to, say, 5), I'll get .10000. Is there some way to always display the number to the left of the decimal point, even if it's a zero (i.e. 0.10000)? 5/2 will get 2.50000, which makes sense.
Thanks for your help.
Last edited by Manifold (2011-12-30 14:40:30)
Offline
Yikes, I just tried to read the bc man page ... not the best is it?
I've been a longtime R user. R is a bit bulkier than bc, but if you're doing anything beyond quick arithmetic I think it would pay off to use R. And R is *very* well documented.
Otherwise best of luck.
Last edited by Trilby (2011-12-30 13:11:22)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Well, I am doing very simple arithmetic. It just so happens that what I want to do concerns fractional quantities and bash arithmetic doesn't like that. I guess I could use R, but ideally I would use bc for its large installation presence...
Last edited by Manifold (2011-12-30 13:22:06)
Offline
Offline
I did something quite similar, but using a bash script to concatene a '0' in front of the decimal place. I just thought there was a simple variable to set that I'd missed but I guess not. I wonder what the design purpose of missing out the 0 on the left hand side of a decimal place is.
Offline
Seems that awk can be a nice calculator too: https://bbs.archlinux.org/viewtopic.php … 64#p717764
[karol@black ~]$ calc 1/10
0.1
It should have a wide installation base too.
Offline
That's a pretty nifty trick. Thanks!
Offline