delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/02/24/11:46:31

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Fibonacci number
Date: 24 Feb 2004 16:38:31 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 31
Message-ID: <c1fum7$hf2$3@nets3.rz.RWTH-Aachen.DE>
References: <d7c3a0b2 DOT 0402220759 DOT 34d6435d AT posting DOT google DOT com> <4038E8CA DOT 6491815E AT virginia DOT edu> <4039DD96 DOT 3F36F3B7 AT yahoo DOT com> <200402231458 DOT i1NEwKwm020904 AT envy DOT delorie DOT com> <403A301C DOT E8F5FE65 AT yahoo DOT com> <200402231751 DOT i1NHp5lv022894 AT envy DOT delorie DOT com> <c1fijm$314$2 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <200402241539 DOT i1OFdSon024698 AT envy DOT delorie DOT com>
NNTP-Posting-Host: ac3b07.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1077640711 17890 137.226.33.205 (24 Feb 2004 16:38:31 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 24 Feb 2004 16:38:31 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

DJ Delorie <dj AT delorie DOT com> wrote:

> > Since negation is a well-defined operation on unsigned longs, there's
> > no error involved.

> This makes no sense.  

I would say it makes exactly as much sense as the fact that 

	unsigned long myvar = -1;

is perfectly legal C.  Some lints and picky compilers may warn about
it, but it's correct C.  

> *All* arithmetic operations are well defined for
> all integer types, but still, POSIX requires a range error.  

Are you sure it require an ERANGE for merely negative numbers, and not
just for values outside the range of +/- ULONG_MAX?  

At least P.J. Plauger's book on the ISO Standard libc implies
otherwise.  To quote him: "The function strtoul reports a range error
only if the converted magnitude is greater than ULONG_MAX, defined in
<limit.h>. ( Negating the value cannot cause overflow.)"

I think we can trust Plauger on this one --- he was in the X3J11
committee, after all.

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019