Talk:Arithmetic/Complex

From Rosetta Code
Revision as of 13:18, 13 March 2008 by rosettacode>Waldorf (Conversion does not help for C)

Ada and C++ both still need negation. I forgot to put it in the Java example before but I added I it later. Sorry for the confusion. --Mwn3d 10:13, 9 March 2008 (MDT)

The Ada entry has been amended to include negation. --Waldorf 14:40, 9 March 2008 (MDT)

I believe the C example is incorrect. The current written example relies upon operator overloading which is not supported by C99.--Waldorf 09:10, 11 March 2008 (MDT)

I did some looking; there are complex built-in types in the C99 standard, with defined implicit casts up and down to the other numeric primitives. --IanOsgood 10:36, 11 March 2008 (MDT)
How could an implicit cast from a complex type to a floating point or integer type result in a valid value? Simple integers and floats cannot represent both the real and imaginary parts of the complex number.--Waldorf 17:36, 11 March 2008 (MDT)
The code example only uses conversions from real types to complex types; but complex types can be converted to real types by discarding the imaginary part. --Spoon! 18:21, 11 March 2008 (MDT)
The code example includes addition, multiplication, and negation using the language-defined operators. In those instances no conversion is possible without loosing information (the imaginary part of the complex number). Without operator overloading no correct result can be obtained. Any implicit conversion will result in loss of the imaginary part of the complex number. The C example must therefore be incorrect.--Waldorf 07:18, 13 March 2008 (MDT)