[Cfp-interest 3328] i suffix warning

Jim Thomas jaswthomas at sbcglobal.net
Tue Nov 19 09:41:58 PST 2024


I suggest that CFP propose adding a note such as the following to accompany the new specification for an imaginary suffix. Here bold indicates code typeface.

NOTE Since i suffixed constants are of complex type and have a +0 real part, their use is problematic where signed zeros and infinities are involved. For example, with ISO/IEC 60559 arithmetic,

-0.0 + 1.0i		yields	-0 + (+0 + i) =  +0 + I
-1.0i 			yields 	-(+0 + i) = -0 - I
INFINITY * 1.0i 	yields 	inf * (+0 + i) = NaN + inf i. 

The CMPLX macros in <complex.h> can be used to straightforwardly obtain particular values involving signed zeros and infinities. For example, corresponding to the cases above,

CMPLX(-0.0, 1.0) 		yields	-0 + I
CMPLX(0.0, -1.0) 		yields 	+0 - I
CMPLX(0.0, INFINITY) 	yields 	+0 + inf i


- Jim Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20241119/3b44089b/attachment.htm>


More information about the Cfp-interest mailing list