Unexpected behaviour of math.floor, round and int functions (rounding)

Grant Edwards grant.b.edwards at gmail.com
Sat Nov 20 20:18:21 EST 2021


On 2021-11-21, Chris Angelico <rosuav at gmail.com> wrote:

>> I think there have been attempts to use a decimal representation in some
>> accounting packages or database applications that allow any decimal numbers
>> to be faithfully represented and used in calculations. Generally this is not
>> a very efficient process but it can handle 0.3 albeit still have no way to
>> deal with transcendental numbers.
>
> Fixed point has been around for a long time (the simplest example
> being "work in cents and use integers"), but actual decimal
> floating-point is quite unusual. Some databases support it, and REXX
> used that as its only numeric form, but it's not hugely popular.

My recollection is that it was quite common back in the days before FP
hardware was "a thing" on small computers. CPM and DOS compilers for
various languages often gave the user a choice between binary FP and
decimal (BCD) FP.

If you were doing accounting you chose decimal. If you were doing
science, you chose binary (better range and precision for the same
number of bits of storage).

Once binary FP hardware became available, decimal FP support was
abandoned.

--
Grant


More information about the Python-list mailing list