[Python-Dev] Floor division (original) (raw)
Guido van Rossum guido at python.org
Mon Jan 22 04:40:21 CET 2007
- Previous message: [Python-Dev] Floor division
- Next message: [Python-Dev] Floor division
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 1/21/07, Tim Peters <tim.peters at gmail.com> wrote:
It's just a fact that different definitions of mod are most useful most often depending on data type. Python's is good for integers and often sucks for floats. The C99 and
decimal
definition(s) is/are good for floats and often suck(s) for integers. Trying to pretend that integers are a subset of floats can't always work ;-)
That really sucks, especially since the whole point of making int division return a float was to make the integers embedded in the floats... I think the best solution would be to remove the definition of % (and then also for divmod()) for floats altogether, deferring to math.fmod() instead.
The ints aren't really embedded in Decimal, so we don't have to do that there (but we could).
The floats currently aren't embedded in complex, since f.real and f.imag don't work for floats (and math.sqrt(-1.0) doesn't return 1.0j, and many other anomalies). That was a conscious decision because complex numbers are useless for most folks. But is it still the right decision, given what we're trying to do with int and float?
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Floor division
- Next message: [Python-Dev] Floor division
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]