This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Creating imaginary inf/nan in GCC


Hi,

I'm trying to create complex number expressions that contain inf or nan in
the imaginary part.  I.e. (0 + inf I) or (0 + nan I).

However when I write (_builtin_nan("") * 1.0i) I get (nan + nan I).  For
(__builtin_inf() * 1.0i) I get (nan + inf I).

I don't think these results are a bug, rather it's just an artifact of the
way complex multiplcation is done and having these special values in
there.  I had a similar problem getting negative zeros in the imaginary
part, but I solved that using conj(0.0) and conj(-0.0).  I don't think
conj helps for inf/nan though.

I know I can simply use a complex variable and set the real/imag parts
separately, but I want a constant expression which I can pass as an
argument to a builtin complex math function for writing testcases that
fold (or not) and compile-time.

Is there a way to get an imaginary inf or nan expression without having
the real part get changed?

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]