Unix – Evaluate Floating point Arithmetic Operation in Unix

By -

Problem: How to evaluate Floating point Arithmetic operation in Unix?

Solution:

In UNIX, as we know, ‘expr’ is used to evaluate arithmetic operation but it is not used to evaluate floating point valued expression. See the below image for more clarification:

Now, One more command is used to evaluate arithmetic expression , i.e. bc command.

Now Question should be such:

How do we evaluate Floating point Arithmetic expression in Unix?

We can mention ‘scale’ command while evaluating an arithmetic expression using ‘bc’ command. Scale command specifies the number of digits after the decimal point.

For example: Look at the below attached image explaining everything about the evaluation of floating point arithmetic expression.

Paresh Mayani

Lazy android developer, exploring the horizon of android development since 7 years. He is Technical Lead - Android at Lets Nurture, India. He is also Application Architect at KarConnect. He is the Head/Organizer of Google Developers Group (GDG), Ahmedabad

Loading Facebook Comments ...
Loading Disqus Comments ...