Path: utzoo!mnetor!uunet!husc6!bbn!rochester!udel!princeton!phoenix!llave From: llave@phoenix.Princeton.EDU (Rafael Llave) Newsgroups: comp.lang.c Subject: Re: Constant overflow Message-ID: <2052@phoenix.Princeton.EDU> Date: 12 Mar 88 23:52:23 GMT References: <2747@mmintl.UUCP> <2550059@hpisod2.HP.COM> Organization: Princeton University, NJ Lines: 15 Summary: Consant overflow In article <2550059@hpisod2.HP.COM>, decot@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.