Constant overflow

Rafael Llave llave at phoenix.Princeton.EDU
Sun Mar 13 09:52:23 AEST 1988


In article <2550059 at hpisod2.HP.COM>, decot at hpisod2.HP.COM (Dave Decot) writes:
 > Try this one on your favorite C compiler.  So far, every one I've tried
 > (including lint) has had no complaint:
 > 
 > 	long i = 9876543210L;
 > 
 > (The problem, of course, is that that number doesn't fit in 32 bits...)

Integer arithmetic is not supposed to overflow and all
integers are  supposed to be taken ss defined modulo a power of 2 which
is implementation dependent. I have seen 
some compilers that at compile time gave you warnings - God
bless them -- but to ensure portability of programs that
have to handle  occasionally large numbers , I have always
included some defensive lines. 



More information about the Comp.lang.c mailing list