Reputation: 196
math 5/2
returns 2.
I want 2.5 -- how do I get decimal values?
Upvotes: 5
Views: 849
Reputation: 21
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
Upvotes: 2
Reputation: 246817
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
Upvotes: 3
Reputation: 1694
you have to force floating point division instead of integer division
math 5/2.0
Upvotes: 1