You can "force" math
to return fractions by default -- use the -l
option to bc
:
$ math 5/2
2
$ function bc
command bc -l $argv
end
$ math 5/2
2.50000000000000000000
Question
math 5/2
returns 2.
I want 2.5 -- how do I get decimal values?
Solution
You can "force" math
to return fractions by default -- use the -l
option to bc
:
$ math 5/2
2
$ function bc
command bc -l $argv
end
$ math 5/2
2.50000000000000000000
OTHER TIPS
Add this to one of your config.fish files
set -x BC_ENV_ARGS ~/.bc.cfg
Then create a .bc.cfg file to tell it out many decimal places to display
echo "scale = 5" >> .bc.cfg
This will:
math 5/2
2.50000
you have to force floating point division instead of integer division
math 5/2.0