🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4617

Re: "for" loops (was Re: C++ vs. Modula2)

#4617
From: Tim Meighan
Date: Tue, 31 Jan 1989 17:32
16 lines
889 bytes
In article <6419@polya.Stanford.EDU> crew@Polya.Stanford.
EDU (Roger Crew) writes:
>Hint:  the answer is *not*
>	char a, b, c;
>	for (c = a; c <= b; ++c) { ... }
>(just try a = 0 and b = 255 in the case of 8 bit chars).

Sure it is.  You need to declare  a, b, and c as:

 unsigned char a, b, c;

Otherwise, setting b = 255 is actually doing this:  b = -128.

Tim Meighan
Network Operations
Silent Radio
Technical Details
Message-ID: <391@srhqla.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bbn!oberon!sm.unisys.com!csun!srhqla!tcm
References: <19579@agate.BERKELEY.EDU> <8515@lanl.gov> <6419@polya.Stanford.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bbn!oberon!sm.unisys.com!csun!srhqla!tcm
From: tcm@srhqla.UUCP (Tim Meighan)
Newsgroups: comp.lang.modula2
Subject: Re: "for" loops (was Re: C++ vs. Modula2)
Message-ID: <391@srhqla.UUCP>
Date: 31 Jan 89 17:32:15 GMT
References: <19579@agate.BERKELEY.EDU> <8515@lanl.gov> <6419@polya.Stanford.EDU>
Reply-To: tcm@srhqla.UUCP (Tim Meighan)
Organization: Silent Radio, Los Angeles
Lines: 16