Article View: comp.std.c
Article #2182Re: should abs() be 'uint'?
From: Eyal Lebedinsky
Date: Thu, 01 Oct 1992 23:00
Date: Thu, 01 Oct 1992 23:00
21 lines
1237 bytes
1237 bytes
Following my original posting on the subject, I think the gravity of the
issue
can be better viewed with examples of past problems. Of course, the
replay of 'the standards seeks backward compatibility' is valid but
should be related to 'past problems' againt 'future problems'.
My most prominent problem:
I keep angles as 16bit signed numbers. 180 degrees (and -180) is
represented as 0x8000. I often seek the magnitude using abs(a) and got
caught a few time. Now I do things like:
d = abs (d)
if (d < 0) {
/* handle special case */
}
which, If I leave out, will have subtle and hard to find effects. The
use of 'int' is most appropriate as I want angles to wrap around in the
range [-180, 180)
Anyone else has pet problems with abs?
Technical Details
Message-ID:
<eyal.717980448@ise>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!manuel!csc.canberra.edu.au!echo!eyalReferences:
<BvAzvK.EFx@zoo.toronto.edu> <1992Sep30.040719.2852@waggen.twuug.com> <BvEp3G.540@zoo.toronto.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!manuel!csc.canberra.edu.au!echo!eyal From: eyal@echo.canberra.edu.au (Eyal Lebedinsky) Subject: Re: should abs() be 'uint'? Message-ID: <eyal.717980448@ise> Sender: news@csc.canberra.edu.au Organization: Info Sci & Eng, University of Canberra, AUSTRALIA References: <BvAzvK.EFx@zoo.toronto.edu> <1992Sep30.040719.2852@waggen.twuug.com> <BvEp3G.540@zoo.toronto.edu> Date: 1 Oct 92 23:00:48 GMT Lines: 21