I just wrote a small bash shell script and for the first time in that context I wanted to make a calculation, a division, and discovered
bc
.
My script processes media files and I want to log the performance, that is, the length of the file divided by the duration of the processing. Typical values for the quotient is 0,03-0,05 but bc doesn't round, it truncates! Which is a problem because the difference between 0,0300 and 0,0399 is quite significant but bc will return 0,03 for both.
I have read multiple questions about making bc round, with mostly quite convoluted solutions. This made me wonder:
**Why doesn't bc have native support for rounding??**
I am not looking for a solution but am curious about the design decisions behind the lack of support for rounding. I am aware of the KISS philosophy but rounding floating point values is such a basic feature for any calculator.
Of course you could display the result with two more digits and the make the rounding manually (in your head), but it is weird to waste human mental energy a task that a computer is much better on performing than a human! Hence my question.
Asked by d-b
(2047 rep)
May 24, 2024, 07:25 PM
Last activity: May 27, 2024, 06:37 PM
Last activity: May 27, 2024, 06:37 PM