Article View: comp.std.c
Article #2172this unsigned business
From: Stephen Friedl
Date: Wed, 30 Sep 1992 22:12
Date: Wed, 30 Sep 1992 22:12
32 lines
1231 bytes
1231 bytes
Hi Folks,
This whole unsigned business has got me thinking about the
portability aspects of a little trick, and I was wondering about
the net.at.large's opinion of it.
Let's say that I've got an int whose legal range is 0 to 100,
and I want to validate it (say) upon entry to a function. Is this
a portable way to do it?
foo(v)
int v;
{
if ( (unsigned int) vu > 100)
printf("value out of range!\n");
/* must be valid */
Note that I am not looking for the aesthetics of this -- it's
a trick that will just confuse somebody -- just whether it is portable
or not. I know that it works on my machine, which doesn't prove
much at all.
Thoughts?
Stephen
--
Stephen J Friedl | Software Consultant | Tustin, CA | +1 714 544-6561
3b2-kind-of-guy | I speak for me ONLY | KA8CMY | uunet!mtndew!friedl
Attorneys are paranoid because they assume everybody else is dishonest too
Technical Details
Message-ID:
<711@mtndew.Tustin.CA.US>Path:
arc1-ca.pugleaf.net!sparky!uunet!mtndew!friedlShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mtndew!friedl From: friedl@mtndew.Tustin.CA.US (Stephen Friedl) Newsgroups: comp.std.c Subject: this unsigned business Message-ID: <711@mtndew.Tustin.CA.US> Date: 30 Sep 92 22:12:00 GMT Organization: Steve's Personal machine / Tustin, CA Lines: 32