Hacker News new | ask | show | jobs
by ibiza 2203 days ago
I use a function "ev" that wraps bc. It's crude, but handy:

    $ ev() { echo "scale=3; $*" | bc -l; }
    
    $ ev 22/7
    3.142
1 comments

I do something similar, with a couple of convenience substitutions for commas and multiplication:

$ math() { echo "scale=2 ; $" | sed -e "s:x::g" | sed -e "s:,::g" | bc; }

$ math 5,382 x 48,927.3

263326728.6

You should put this into a codeblock by indenting by 2 spaces. The formatting converts asterisk-delimited text into italics.

  $ math() { echo "scale=2 ; $*" | sed -e "s:x:*:g" | sed -e "s:,::g" | bc; }
  
  $ math 5,382 x 48,927.3
  
  263326728.6