[comp.std.c] What type is yielded by bitwise & | ^

rfg@lupine.ncd.com (Ron Guilmette) (12/03/90)

The title line pretty much says it.

Perhaps I'm looking at an old draft standard when I should be looking
at something newer, but what I really need to know this and I hope
somebody will help me out.

(I know... I know... you want to know which way I came in. :-)

It looks to me like the sections of the standard which describe most
of the binary operators also state explicitly what the type of the
result will be.

In the case of bitwise-and, bitwise-ior, and bitwise-xor however I can't
see where the result type is defined.

Harbison & Steel say that the result type for these is the same as the
(promoted) operands, but I'd like to know where it says that in the
actual standard document.

Also, while we are on the subject...

Given some binary operator `@', and given:

	int i;
	long l;

		... i @ l ...

where does the standard say that `i' must get implicitly widened to
match `l'?  Is that even required for EACH AND EVERY binary operator?
How about:

		... l << i ...
		... i << l ...

Is there any reason to widen `i' in either of these cases?

If operands of binary operators are implicitly coerced to be the same
type before the operation is actually performed, and if this only happens
for some subset of C's binary operators, then please tell me which binary
operators (specifically) this rule applies to.

Thanks.

gwyn@smoke.brl.mil (Doug Gwyn) (12/03/90)

In article <2881@lupine.NCD.COM> rfg@lupine.ncd.com (Ron Guilmette) writes:
>In the case of bitwise-and, bitwise-ior, and bitwise-xor however I can't
>see where the result type is defined.

The standard says that the usual arithmetic conversions are applied.
Section 3.2.1.5 explains what this means.