| Deutsch English Français Italiano |
|
<v847r9$3kh8o$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Newsgroups: comp.arch
Subject: Re: a bit of history, Stealing a Great Idea from the 6600
Date: Sun, 28 Jul 2024 01:45:14 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <v847r9$3kh8o$2@dont-email.me>
References: <71acfecad198c4e9a9b14ffab7fc1cb5@www.novabbs.org>
<lm8YN.7354$qdt5.2292@fx35.iad> <v0rhj5$1itj$2@gal.iecc.com>
<2024May3.173347@mips.complang.tuwien.ac.at> <v139qt$121r$1@gal.iecc.com>
<v151fp$15b28$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 28 Jul 2024 03:45:14 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3b558a041f0a0aed486aeb8fa027d259";
logging-data="3818776"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Zk9n3vl8VUbKmKTCfCZZq"
User-Agent: Pan/0.159 (Vovchansk; )
Cancel-Lock: sha1:lZfpDE8fj/EupmmmNUFQRyyWr3s=
On Sat, 4 May 2024 10:08:57 -0000 (UTC), Thomas Koenig wrote:
> Just think of doing a unsigned loop with a lower bound that, due to some
> error in the code or input, has an upper bound of 0-1...
Using the entire range of an unsigned integer type takes some care, but
can be done:
unsigned int i;
bool found;
...
/* length of s might be anything up to largest unsigned integer */
for (i = len(s);;)
{
if (i == 0)
{
found = false;
break;
} /*if*/
--i;
if (matches(s[i]))
{
found = true;
break
} /*if*/
} /*for*/
/* at this point, i will point to the matching element if found */