Search code examples
fish

How to get decimal value from divide in fish shell


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