문제

math 5/2 returns 2.

I want 2.5 -- how do I get decimal values?

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top