Article View: comp.std.c
Article #2164Re: should abs() be 'uint'?
From: Joe Wright
Date: Wed, 30 Sep 1992 04:07
Date: Wed, 30 Sep 1992 04:07
8 lines
870 bytes
870 bytes
Aren't we missing the point here? The whole point of abs() is to take a signed value and return a positive result. The only two's complement number that gives a problem is the 'most negative' 0x80..00 because it does not have a positive counterpart. So what? If the tested value can actually range to -32768 (16 bits) we are using the wrong type. Use the next larger type (long?) instead. -- Joe Wright alpha@waggen.twuug.com
Technical Details
Message-ID:
<1992Sep30.040719.2852@waggen.twuug.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!uakari.primate.wisc.edu!daffodil!wyvern!waggen!alphaReferences:
<BvAzvK.EFx@zoo.toronto.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sdd.hp.com!uakari.primate.wisc.edu!daffodil!wyvern!waggen!alpha From: alpha@waggen.twuug.com (Joe Wright) Subject: Re: should abs() be 'uint'? Message-ID: <1992Sep30.040719.2852@waggen.twuug.com> Organization: ALPHA, Box 68621, Va. Beach, VA 23455 X-Newsreader: TIN [version 1.1 PL6] References: <BvAzvK.EFx@zoo.toronto.edu> Date: Wed, 30 Sep 1992 04:07:19 GMT Lines: 8