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.

CEO & Co-Founder at SolGuruz® | Organiser @ GDG Ahmedabad | Top 0.1% over StackOverflow | 15+ years experienced Tech Consultant | Helping startups with Custom Software Development

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