4 ms·
As far as I know, BC doesn't do floating point arithmetic. It does fixed point arithmetic, built on top of arbitrary-precision integer arithmetic. Which is why
by yakubin 6y ago
As far as I know, BC doesn't do floating point arithmetic. It does fixed point arithmetic, built on top of arbitrary-precision integer arithmetic. Which is why it won't give you one of those funny floating point answers. It's what a human would do on a piece of paper.
Floating point implementations can vary not only between languages, but also between different CPUs, if the language relies on the hardware implementation (which is the smart thing to do in most cases).
As a side note: Python's implementation of FP isn't standard-compliant. E.g. when you divide by 5.0 by 0.0, the standard says you should get a +inf. In Python you get an exception.
- adrian_b 6y agoActually, according to the standard, you should get either +inf or an exception. Both behaviors are valid. Nevertheless, according to the standard, the user should be able to choose between getting +inf and getting an exception. If in Python there is no way to mask the divide by zero exception, then that is not standard-compliant.