checking for overflow in C

John Hascall hascall at atanasoff.cs.iastate.edu
Wed May 10 23:53:05 AEST 1989


In article <8172 at june.cs.washington.edu> ka at june.cs.washington.edu (Kenneth Almquist) writes:
>In article <1989May9.183140.1770 at utzoo.uucp>, henry at utzoo.uucp (Henry Spencer) writes:
>> In article <8143 at june.cs.washington.edu> ka at june.cs.washington.edu (Kenneth Almquist) writes:
 
>OK, I think I see your point.  My assumption is that the cost isn't a
>big issue because the programmer wouldn't test for overflow unless it
>was necessary.  You would see an *occasional* test such as:
 
>	  new C keyword
>		|
>		v
>	if (overflow a = b * c)
>		printf("Multiplication overflowed\n");
>	else
>		printf("%d * %d = %d\n", b, c, a);
 

     Oh, help us please!!!!

     What are you people trying to do?  Turn C into PL/1?

     If this overflow business is important to you (and it certainly is
     for some)...  Why not use SIGFPE?  This works (is documented to work,
     I've never had occasion to try it) under BSD on the VAX, perhaps
     it works on your machine as well.  Did ANSI have anything to say
     on this topic?


     John Hascall
     ISU Comp Center



More information about the Comp.lang.c mailing list