Search code examples
linuxbashbc

bc truncate floating point number


How do I truncate a floating point number using bc

e.g if I do

echo '4.2-1.3' | bc

which outputs 2.9 how I get it to truncate/use floor to get 2


Solution

  • Use / operator.

    echo '(4.2-1.3) / 1' | bc