DIGIT-ARC read-only archive · snapshot: July 23, 2026

How to do floating point arithmetic in Shell programming?

3 posts · originally from https://geek.digit.in/community/threads/how-to-do-floating-point-arithmetic-in-shell-programming.7374/

hafees
hafees Original post #1
Mar 25, 2005 at 12:07 AM
:)
is there any direct method to do floating point arithmetics in shell programming ? using expr or something. pls help
GNUrag
GNUrag #2
Mar 27, 2005 at 5:12 PM
You can use expr to evaluate expressions like you'd have seen in many shell tutorials.

But for floating point maths you can use the bc utility. GNU bc does not require the separate dc program, which is another GNU calculator utility

Read this example cum documentation to understand how to invoke and integrate bc with your shell script.
*www.gnu.org/software/bc/manual/html_mono/bc.html#SEC19
hafees
hafees #3
Mar 28, 2005 at 12:32 AM
i ve saved the page. thnx. :)