Reputation: 6845
I read from a passage that
Unlike most programming languages, BASH does not have builtin floating point math (it does have builtin integer math, however).
However, I can still do
echo "5.0>5.9" | bc -l
0
echo "5.0+5.9" | bc -l
10.9
These are floating point numbers; why does bc
still work in these situations?
Upvotes: 0
Views: 160
Reputation: 3295
The expressions 5.0>5.9
and 5.0+5.9
are sent to bc
, which is a stand-alone program.
Upvotes: 3
Reputation: 70245
The Unix utility bc
is not part of Bash
. The echo
produces characters on its standard output; bc
takes its standard input and performs math operations. All that bash
is doing in this case is stringing together the standard output to standard input implied by the |
operator.
Upvotes: 5