# [Python-Dev] Revised decimal type PEP

**Guido van Rossum
**
guido@zope.com

*Mon, 30 Jul 2001 16:42:05 -0400*

Michael's PEP touches upon the one difficult area of decimal
semantics: what to do when a decimal and a binary float meet?
We discussed this briefly over lunch here and Tim pointed out that the
default should probably be an error: code expecting to work with
exact decimals should be allowed to continue after contamination with
an inexact binary float.
But in other contexts it would make more sense to turn mixed operands
into inexact, like what currently happens when int/long meets float.
In the IBM model that Aahz is implementing, decimal numbers are not
necessarily exact, but (if I understand correctly) you can set a
context flag that causes an exception to be raised when the result of
an operation on two exact inputs is inexact. This can happen when
e.g. a multiplication result exceeds the number of significant digits
specified in the context -- then truncation is applied like for binary
floats.
Could the numeric tower look like this?
int < long < decimal < rational < float < complex
******************************* ***************
exact inexact
A numeric context could contain a flag that decides what happens when
exact and inexact are mixed.
--Guido van Rossum (home page: http://www.python.org/~guido/)