Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!adm!MAILER%ALASKA.BITNET@CUNYVM.CUNY.EDU From: MAILER%ALASKA.BITNET@CUNYVM.CUNY.EDU Newsgroups: comp.lang.c Subject: Undelivered mail Message-ID: <12353@brl-adm.ARPA> Date: 13 Mar 88 10:57:21 GMT Sender: news@brl-adm.ARPA Lines: 32 Subject: Re: Constant overflow [Non-Deliverable: User does not exist or has never logged on] Reply-To: Info-C@BRL.ARPA Received: From UWAVM(MAILER) by ALASKA with Jnet id 0614 for SXJVK@ALASKA; Sun, 13 Mar 88 01:38 AST Received: by UWAVM (Mailer X1.25) id 6629; Sun, 13 Mar 88 02:38:29 PST Date: Sat, 12 Mar 88 23:52:23 GMT Reply-To: Info-C@BRL.ARPA Sender: Info-C List From: Rafael Llave Subject: Re: Constant overflow Comments: To: info-c@BRL-SMOKE.arpa To: Vic Kapella 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.