Talk:Arithmetic/Complex: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
: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. --[[User:IanOsgood|IanOsgood]] 10:36, 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. --[[User:IanOsgood|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.--[[User:Waldorf|Waldorf]] 17: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.--[[User:Waldorf|Waldorf]] 17:36, 11 March 2008 (MDT) |
||
:: |
:: Same way (int)1.5 isn't valid. A down-cast would strip the imaginary part. Implicit up-casts are the the more useful case anyway, allowing scalar/complex arithmetic. --[[User:IanOsgood|IanOsgood]] 10:57, 12 March 2008 (MDT) |
Revision as of 16:57, 12 March 2008
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)
- Same way (int)1.5 isn't valid. A down-cast would strip the imaginary part. Implicit up-casts are the the more useful case anyway, allowing scalar/complex arithmetic. --IanOsgood 10:57, 12 March 2008 (MDT)