# Fixing the imaginary/complex mess

Jason House jason.james.house at gmail.com
Mon May 4 05:33:05 PDT 2009

```Frits van Bommel Wrote:

> Don wrote:
> > In the case complex = int/complex, there's no problem. It's the case int
> > = int/complex that doesn't make sense.
> > And that's fundamentally because cast(real)(2 + 3i) doesn't have a
>
> Devil's advocate: one could argue it's the same as cast(int) of a float -- it
> returns the closest representable value, for some definition of "closest".

I consider this to be a much different case. Assuming the float to an int results on approximately the same number... And everyone knows what to expect. It's also possible to convert back to float and still have approximately the same number.

For complex to int, the same things are not true. Conversion to float and then back to real can give a much different number... And not just for overflow, but normal uses of complex numbers. It's also unclear to mathematically inclined folk like me and Don what the conversion is supposed to do. A magnitude makes as much, if not more, sense.

Adding to all this, there are easier, shorter, and clearer ways to do all of these conversions, and you _have_ to agree with Don ;)

```