[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Request for enhancement: links to 'true' and 'false'
From: |
Jeffrey Streifling |
Subject: |
Re: Request for enhancement: links to 'true' and 'false' |
Date: |
Mon, 22 Apr 2013 13:21:14 -0600 |
What bc can do that expr can't is arbitrary precision, arbitrary scale, arbitrary base arithmetic, complete with transcendentals. You can do tricks with bc that elude most other tools. The benefit of doing math in the shell is that everything is a string until stated otherwise, and you can efficiently combine the strengths of various external specialized _expression_ evaluators. The pain is doing comparisons and branching. The most general method is probably, 'bc <<< "...comparison _expression_..." | grep -q 1', or, portably, 'printf "...comparison _expression_...\n" |bc|grep -q ^1$'. Indeed, portable probably wins here despite being a little less expressive, and probably justifies cancelling my feature request . . .