Message 337466 - Python tracker (original) (raw)
So I suggest:
- Methods floor and ceil for complex object.
What's the use-case for these? It's not a particularly natural operation, and I've never had a need for a complex "floor" operation, either as a mathematician or as a developer. Do you have an example of real-world code that would benefit?
For those rare cases where this is needed, it isn't that hard to spell out complex(floor(z.real), floor(z.imag))
, or to write a custom complex_floor
function.
Also, what type should math.floor
return when applied to a complex number? math.floor
of a float
object returns an int
, so the analogous operation on a complex number should return a Gaussian integer. But we don't have a Gaussian integer type in standard Python, and it wouldn't be appropriate to add one.