3 ms·
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 .5
by brute 12y ago
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
- tartrate 12y agoSlightly shorter, and it's nice to have the expression at the end of the line: $ bc -l <<< "1+1"