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.
your expected result would be with 3 decimal points. You should note that there is there is no rounding off done by bc.
Now in bash you can use the printf function to do the rounding off that you require. Use scale = 4 and then use printf to round off to 3 decimal points using "%.3f"
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Arithmetic Operations
You are viewing a single comment's thread. Return to all comments →
When you use
your expected result would be with
3
decimal points. You should note that there is there is no rounding off done by bc.Now in bash you can use the printf function to do the rounding off that you require. Use
scale = 4
and then use printf to round off to 3 decimal points using"%.3f"