We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 328d9ca commit 8ebc9fcCopy full SHA for 8ebc9fc
src/math.sh
@@ -3,9 +3,11 @@
3
function math::calculate() {
4
if dependencies::has_bc; then
5
echo "$*" | bc
6
- elif dependencies::has_awk; then
+ elif [[ "$*" == *.* ]] && dependencies::has_awk; then
7
+ # Use awk for floating point calculations when bc is unavailable
8
awk "BEGIN { print ($*) }"
9
else
10
+ # Fallback to shell arithmetic which has good integer precision
11
local result=$(( $* ))
12
echo "$result"
13
fi
0 commit comments