We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

Having the same issues as everyone else here; scale = 3 gives 17.928 NOT 17.929. Although I know that the answer should be 17.929, quite an odd problem.

EDIT:

You need to use the printf method for it to work, the reason is that -bc literally chops off the end of the number instead of actually rounding.

the actual answer is 17.9285 - which needs to be (upgraded) to 17.929
the reason why most people faltered is because they truncated rather than rounding off.

Would have been nice if there was an info on that in the problem description... bc -l is described in great detail and used but nowhere is it pointed out that it truncates, or that the problem would need proper roundings... pretty frustrating, as arithmetical rounding is hardly ever requested in CS problems and everybody is fine with truncating...

## Arithmetic Operations

You are viewing a single comment's thread. Return to all comments →

Having the same issues as everyone else here;

`scale = 3`

gives 17.928 NOT 17.929. Although I know that the answer should be 17.929, quite an odd problem.EDIT:

You need to use the

`printf`

method for it to work, the reason is that`-bc`

literally chops off the end of the number instead of actually rounding.the actual answer is 17.9285 - which needs to be (upgraded) to 17.929 the reason why most people faltered is because they truncated rather than rounding off.

Would have been nice if there was an info on that in the problem description... bc -l is described in great detail and used but nowhere is it pointed out that it truncates, or that the problem would need proper roundings... pretty frustrating, as arithmetical rounding is hardly ever requested in CS problems and everybody is fine with truncating...

It was in the "PROBLEM" : **Your task is to evaluate the expression and display the correct output rounding upto decimal places. **

Why did this comment get -31?

read num echo $num | bc -l | xargs printf "%.*f\n" 3