Decimal calculations are sometimes required in Bash. The standard calculation Bash programming idiom ($[]) is unable to provide a decimal output. Whilst we can trick it into calculating (but not generating) a decimal output by multiplying the numbers by for example a factor of 1000 and then doing an text based splitting, this is a ugly workaround and creates complex code. There is however a utility in Bash which can natively do decimal based calculations without any tricks or workarounds!

This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-make-decimal-calculations-in-bash-using-bc