[Python-Dev] trunc() (original) (raw)
Christian Heimes lists at cheimes.de
Sat Jan 26 23:23:40 CET 2008
- Previous message: [Python-Dev] trunc()
- Next message: [Python-Dev] trunc()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jeffrey Yasskin wrote:
This interpretation implies that complex should provide float() to return the non-imaginary portion of a complex number. Is that what you intend?
No, please don't. If somebody wants to implement float for complex numbers please define it as hypot(complex) / sqrt(c.real2 + c.img2).
In my opinion float(complex) does do the most sensible thing. It fails and points the user to abs().
float(complex(1,1)) Traceback (most recent call last): File "", line 1, in TypeError: can't convert complex to float; use abs(z) abs(complex(1,1)) 1.4142135623730951
- Previous message: [Python-Dev] trunc()
- Next message: [Python-Dev] trunc()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]