Incrementing after a cast
Joseph S. D. Yao
jsdy at hadron.UUCP
Fri Jan 2 22:13:19 AEST 1987
In article <2029 at brl-adm.ARPA> .csnet"@relay.cs.net> writes:
(Something confused, including:)
> "Think of the bits refered to as p as a (sometype *).
> If don't have enough bits or you have too many bits
> do something reasonable. Now increment the (sometype *)
> you're thinking of. Now put the results back into p.
> If you don't have enough bits or you have too many bits,
> do something reasonable."
Others have already commented on special-casing, models of
computation, and the like, and I couldn't do it better.
Let me pick at this a moment.
First, "increment": what's the sizeof(bits)? By how much does
one increment?
Second: "something reasonable": I w i l l pick at this, despite
your request. There is a good model (modulo arithmetic) for
what to do if different integers are different sizes. What
model do you propose for pointers? For s t r u c t u r e s ?
C gives warnings on some casts, anyway; now you want to make
this even worse?
Third: what is wrong with (*sigh*):
type1 p;
p = (type1) ((type2)p + 1);
If anyone replies with "too many keystrokes" I am not responsible
for the responses he or she gets. From anyone. Self included.
--
Joe Yao hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}
jsdy at hadron.COM (not yet domainised)
More information about the Comp.lang.c
mailing list