Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 3686 - common type of imaginary and non-imaginary should be complex #198

Closed
wants to merge 1 commit into from

Conversation

yebblies
Copy link
Member

@yebblies yebblies commented Jul 3, 2011

Issue 3686 - common type of imaginary and non-imaginary should be complex

Update implicit conversion tables and disable remove special casing from AddExp and MinExp.

http://d.puremagic.com/issues/show_bug.cgi?id=3686

…plex

Update implicit conversion tables and disable remove special casing from AddExp and MinExp.
@donc
Copy link
Collaborator

donc commented Jul 3, 2011

Does this deal with *, / correctly?
imaginary * real is imaginary, not complex.

@yebblies
Copy link
Member Author

yebblies commented Jul 3, 2011

Yes, they seem to be. The type of most operations is special cased for mixed real and imaginary arguments. I removed the special casing on addition and subtraction as they should follow the common type rules.

@donc
Copy link
Collaborator

donc commented Jul 3, 2011

Having thought about this a bit more, I'm certain the conclusion of the bug report is wrong --
cond ? real : imaginary
should simply be rejected. If it occurs in code, it's almost certainly a bug. For example, cond ? sqrt(-1.0) : 2i;
Note that real does NOT implicitly convert to complex (and nor does imaginary).
The reason for imaginary types to exist is that they represent complex numbers where the real part is exactly zero -- not +0.0 or -0.0. This can't be represented perfectly in a complex type.

More importantly, I don't know how that behaviour can be implemented when Complex and Imaginary become built-in types.

@yebblies
Copy link
Member Author

yebblies commented Jul 3, 2011

I'll trust your expertise on this. Anything is better than the common type of float and ifloat being float.

@yebblies yebblies closed this Jul 3, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants