PDA

View Full Version : How to do floating point arithmetic in Shell programming?


hafees
25-03-2005, 12:07 AM
:)
is there any direct method to do floating point arithmetics in shell programming ? using expr or something. pls help

GNUrag
27-03-2005, 05: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.
http://www.gnu.org/software/bc/manual/html_mono/bc.html#SEC19

hafees
28-03-2005, 12:32 AM
i ve saved the page. thnx. :)