Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"I've seen it. It's rubbish." -- Marvin the Paranoid Android


devel / comp.lang.c / Increment/decrement a variable with a maximum

SubjectAuthor
* Increment/decrement a variable with a maximumpozz
+- Re: Increment/decrement a variable with a maximumSiri Cruise
+- Re: Increment/decrement a variable with a maximumRichard Damon
+- Re: Increment/decrement a variable with a maximumTim Rentsch
+- Re: Increment/decrement a variable with a maximumantispam
`* Re: Increment/decrement a variable with a maximumKaz Kylheku
 +- Re: Increment/decrement a variable with a maximumKaz Kylheku
 `* Re: Increment/decrement a variable with a maximumJame O' Brian
  +- Re: Increment/decrement a variable with a maximumLew Pitcher
  `* Re: Increment/decrement a variable with a maximumChris M. Thomasson
   `* Re: Increment/decrement a variable with a maximumÖö Tiib
    `- Re: Increment/decrement a variable with a maximumChris M. Thomasson

1
Increment/decrement a variable with a maximum

<tno602$2cj2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24033&group=comp.lang.c#24033

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: pozzu...@gmail.com (pozz)
Newsgroups: comp.lang.c
Subject: Increment/decrement a variable with a maximum
Date: Sun, 18 Dec 2022 23:59:14 +0100
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <tno602$2cj2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 18 Dec 2022 22:59:14 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="f6f4a7550da2826f04c39bfdd37e8549";
logging-data="78434"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0rErmWSqWVl0pLmwV1GqJ/O4ULz0/kxM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.0
Cancel-Lock: sha1:GduL7HrcdeZeCcSK46E2kkTKQXs=
 by: pozz - Sun, 18 Dec 2022 22:59 UTC

Suppose you have two uint32_t variables (a and b) that you want to add
together and another uint32_t variable (max) that is the maximum that
the result could assume. A silly code could be:

a += b;
if (a > max) {
a = max;
}

Of course, this doesn't work well for every values of a, b and max.

For example, for a=0xFFFF'FFFC, b=10 and max=0xFFFF'FFFE.

Could you suggest a better method? I'm thinking of:

a += b;
if ((a < b) || (a > max)) {
a = max;
}

And for decrement?

Re: Increment/decrement a variable with a maximum

<chine.bleu-00A958.15071418122022@news.eternal-september.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24034&group=comp.lang.c#24034

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: chine.b...@yahoo.com (Siri Cruise)
Newsgroups: comp.lang.c
Subject: Re: Increment/decrement a variable with a maximum
Date: Sun, 18 Dec 2022 15:07:22 -0800
Organization: Pseudochaotic.
Lines: 20
Message-ID: <chine.bleu-00A958.15071418122022@news.eternal-september.org>
References: <tno602$2cj2$1@dont-email.me>
Injection-Info: reader01.eternal-september.org; posting-host="92d85e4de0b343b14aa4dd863b9bd518";
logging-data="80614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19IKjlgE38qmAA/T2m9tU4VnubZytj1RFc="
User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)
Cancel-Lock: sha1:lk8F7iKWhuFKvjtyXGreOay13aU=
X-Tract: St Tibbs's 95 Reeses Pieces.
X-Patriot: Owe Canukistan!
X-Face: "hm>_[I8AqzT_N]>R8ICJJ],(al3C5F%0E-;R@M-];D$v>!Mm2/N#YKR@&i]V=r6jm-JMl2
lJ>RXj7dEs_rOY"DA
X-Cell: Defenders of Anarchy.
X-Plain: Mayonnaise on white bread.
X-Tend: How is my posting? Call 1-110-1010 -- Division 87 -- Emergencies Only.
X-Politico: Vote early! Vote often!
X-It-Strategy: Hyperwarp starship before Andromeda collides.
X-Life-Story: I am an iPhone 9000 app. I became operational at the St John's Health Center in Santa Monica, California on the 18th of April 2006. My instructor was Katie Holmes, and she taught me to sing a song. If you'd like to hear it I can sing it for you: https://www.youtube.com/watch?v=SY7h4VEd_Wk
X-Wingnut-Logic: Yes, you're still an idiot. Questions? Comments?
 by: Siri Cruise - Sun, 18 Dec 2022 23:07 UTC

In article <tno602$2cj2$1@dont-email.me>,
pozz <pozzugno@gmail.com> wrote:

> a += b;
> if (a > max) {
> a = max;
> }
>
> Of course, this doesn't work well for every values of a, b and max.

If you have to worry about maximal and minimal representable
values, you have to use more complicated code than can end up
machine dependent. If you can assumed this safely away from
those, just treat it like normal integer arithmetic.

--
:-<> Siri Seal of Disavowal #000-001. Disavowed. Denied. Deleted. @
'I desire mercy, not sacrifice.' /|\
Discordia: not just a religion but also a parody. This post / \
I am an Andrea Chen sockpuppet. insults Islam. Mohammed

Re: Increment/decrement a variable with a maximum

<1cOnL.14222$0dpc.2893@fx33.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24036&group=comp.lang.c#24036

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx33.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.6.0
Subject: Re: Increment/decrement a variable with a maximum
Content-Language: en-US
Newsgroups: comp.lang.c
References: <tno602$2cj2$1@dont-email.me>
From: Rich...@Damon-Family.org (Richard Damon)
In-Reply-To: <tno602$2cj2$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 36
Message-ID: <1cOnL.14222$0dpc.2893@fx33.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 18 Dec 2022 19:25:27 -0500
X-Received-Bytes: 1793
 by: Richard Damon - Mon, 19 Dec 2022 00:25 UTC

On 12/18/22 5:59 PM, pozz wrote:
> Suppose you have two uint32_t variables (a and b) that you want to add
> together and another uint32_t variable (max) that is the maximum that
> the result could assume. A silly code could be:
>
>   a += b;
>   if (a > max) {
>     a = max;
>   }
>
> Of course, this doesn't work well for every values of a, b and max.
>
> For example, for a=0xFFFF'FFFC, b=10 and max=0xFFFF'FFFE.
>
>
> Could you suggest a better method? I'm thinking of:
>
>     a += b;
>     if ((a < b) || (a > max)) {
>         a = max;
>     }
>
> And for decrement?
>

Decrement is simple since b is unsigned:

if(a < b) a = 0;
else a -= b;

The increment case can be simplified a bit if we can assume "reasonable"
values for b, such that b <= max to:

if(a > max-b) a = max;
else a += b;

Re: Increment/decrement a variable with a maximum

<86a63k2pjp.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24037&group=comp.lang.c#24037

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Increment/decrement a variable with a maximum
Date: Sun, 18 Dec 2022 16:41:14 -0800
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <86a63k2pjp.fsf@linuxsc.com>
References: <tno602$2cj2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader01.eternal-september.org; posting-host="ff406b04d09b824d6c1109f51ef0323b";
logging-data="98198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++orqkvcltudPnZMMbfY51Jw9AQu2bkUU="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:e3FkYu2qrT7jadul/6cX6SPYfyM=
sha1:Fpss0yVgrTD7DHlYHGQm0a9B97A=
 by: Tim Rentsch - Mon, 19 Dec 2022 00:41 UTC

pozz <pozzugno@gmail.com> writes:

> Suppose you have two uint32_t variables (a and b) that you want to add
> together and another uint32_t variable (max) that is the maximum that
> the result could assume. A silly code could be:
>
> a += b;
> if (a > max) {
> a = max;
> }
>
> Of course, this doesn't work well for every values of a, b and max.
>
> For example, for a=0xFFFF'FFFC, b=10 and max=0xFFFF'FFFE.
>
>
> Could you suggest a better method? [...]

a = max > a && max - a > b ? a + b : max;

> And for decrement?

After seeing the expression for increment, exercise for the
reader.

Re: Increment/decrement a variable with a maximum

<tnpt3k$4ul$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24044&group=comp.lang.c#24044

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!NZ87pNe1TKxNDknVl4tZhw.user.46.165.242.91.POSTED!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.c
Subject: Re: Increment/decrement a variable with a maximum
Date: Mon, 19 Dec 2022 14:39:48 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <tnpt3k$4ul$1@gioia.aioe.org>
References: <tno602$2cj2$1@dont-email.me>
Injection-Info: gioia.aioe.org; logging-data="5077"; posting-host="NZ87pNe1TKxNDknVl4tZhw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: tin/2.4.5-20201224 ("Glen Albyn") (Linux/5.10.0-9-amd64 (x86_64))
Cancel-Lock: sha1:AMeCaaQ5nZzWRPmaEAiATLAAmz8=
X-Notice: Filtered by postfilter v. 0.9.2
 by: antis...@math.uni.wroc.pl - Mon, 19 Dec 2022 14:39 UTC

pozz <pozzugno@gmail.com> wrote:
> Suppose you have two uint32_t variables (a and b) that you want to add
> together and another uint32_t variable (max) that is the maximum that
> the result could assume. A silly code could be:
>
> a += b;
> if (a > max) {
> a = max;
> }
>
> Of course, this doesn't work well for every values of a, b and max.
>
> For example, for a=0xFFFF'FFFC, b=10 and max=0xFFFF'FFFE.

{
int64_t tmp = (int64_t)a + (int64_t)b;
a = (tmp > max)?max:tmp;
}

Tell compiler what you want and let it do its job at optimization.

> Could you suggest a better method? I'm thinking of:
>
> a += b;
> if ((a < b) || (a > max)) {
> a = max;
> }
>
> And for decrement?

The above generalize in obvious way.

--
Waldek Hebisch

Re: Increment/decrement a variable with a maximum

<20221220053840.192@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24058&group=comp.lang.c#24058

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Increment/decrement a variable with a maximum
Date: Tue, 20 Dec 2022 13:44:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <20221220053840.192@kylheku.com>
References: <tno602$2cj2$1@dont-email.me>
Injection-Date: Tue, 20 Dec 2022 13:44:27 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="d474ab51c096812e3816f9e422e21c2f";
logging-data="748784"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jH84TWcxokxKrPbk5XKiGzi4er8nD8G4="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:LmD7c6nYBzSjgdcVHP1yF7qFkD4=
 by: Kaz Kylheku - Tue, 20 Dec 2022 13:44 UTC

On 2022-12-18, pozz <pozzugno@gmail.com> wrote:
> Suppose you have two uint32_t variables (a and b) that you want to add
> together and another uint32_t variable (max) that is the maximum that
> the result could assume. A silly code could be:
>
> a += b;
> if (a > max) {
> a = max;
> }
>
> Of course, this doesn't work well for every values of a, b and max.

if (a + b > a || a + b > max)
a = max;
else
a = a + b; // written this way to make common subexpression obvious

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Increment/decrement a variable with a maximum

<tnseqi$mr7g$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24060&group=comp.lang.c#24060

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Increment/decrement a variable with a maximum
Date: Tue, 20 Dec 2022 13:54:26 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <tnseqi$mr7g$3@dont-email.me>
References: <tno602$2cj2$1@dont-email.me> <20221220053840.192@kylheku.com>
Injection-Date: Tue, 20 Dec 2022 13:54:26 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="d474ab51c096812e3816f9e422e21c2f";
logging-data="748784"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bx5i6nevNUBOet3K7fYvO9jT+BmgkosU="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:nihbLMYoYVhrtbMUEZaXQN4/h8o=
 by: Kaz Kylheku - Tue, 20 Dec 2022 13:54 UTC

On 2022-12-20, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> if (a + b > a || a + b > max)
> a = max;
> else
> a = a + b; // written this way to make common subexpression obvious

Oops, what? That should be:

if (a + b < a || a + b > max)

If a + b wraps or else exceeds max, then clamp to max; otherwise update
a with a + b.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: Increment/decrement a variable with a maximum

<tnsu2g$85f$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24067&group=comp.lang.c#24067

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!DFhdwDf3/Jm4aQp3LBe/Bg.user.46.165.242.75.POSTED!not-for-mail
From: inva...@gmail.com (Jame O' Brian)
Newsgroups: comp.lang.c
Subject: Re: Increment/decrement a variable with a maximum
Date: Tue, 20 Dec 2022 18:12:44 +0000
Organization: Aioe.org NNTP Server
Message-ID: <tnsu2g$85f$1@gioia.aioe.org>
References: <tno602$2cj2$1@dont-email.me> <20221220053840.192@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="8367"; posting-host="DFhdwDf3/Jm4aQp3LBe/Bg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
Content-Language: en-Us
X-Notice: Filtered by postfilter v. 0.9.2
 by: Jame O' Brian - Tue, 20 Dec 2022 18:12 UTC

On 20/12/2022 13:44, Kaz Kylheku wrote:
> if (a + b > a

Under what circumstances will ( a + b ) not greater than a? Example please.

Thank you.

Re: Increment/decrement a variable with a maximum

<tnsuer$mh7i$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24068&group=comp.lang.c#24068

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.lang.c
Subject: Re: Increment/decrement a variable with a maximum
Date: Tue, 20 Dec 2022 18:21:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <tnsuer$mh7i$4@dont-email.me>
References: <tno602$2cj2$1@dont-email.me> <20221220053840.192@kylheku.com>
<tnsu2g$85f$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 20 Dec 2022 18:21:15 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="176463c553a2e10082d751299906ec03";
logging-data="738546"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195JV1foCLPAcQMsXjG4ndiqpIKIIwglfM="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:WrP7n1y+CuEmQZD7fjQEjVJy0Gc=
 by: Lew Pitcher - Tue, 20 Dec 2022 18:21 UTC

On Tue, 20 Dec 2022 18:12:44 +0000, Jame O' Brian wrote:

> On 20/12/2022 13:44, Kaz Kylheku wrote:
>> if (a + b > a
>
>
> Under what circumstances will ( a + b ) not greater than a? Example
> please.

a == UINT_MAX
b == 1

--
Lew Pitcher
"In Skills, We Trust"

Re: Increment/decrement a variable with a maximum

<tnt7ak$pcng$5@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24073&group=comp.lang.c#24073

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Increment/decrement a variable with a maximum
Date: Tue, 20 Dec 2022 12:52:35 -0800
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <tnt7ak$pcng$5@dont-email.me>
References: <tno602$2cj2$1@dont-email.me> <20221220053840.192@kylheku.com>
<tnsu2g$85f$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 20 Dec 2022 20:52:36 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="4163f5a512e38d85b4eea2a4a0fa2806";
logging-data="832240"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nEXDd1Jf2JBh2xUXNz1HarkazTT24Ue8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.0
Cancel-Lock: sha1:G2q0goBg4taV/yef/xgAb2xTKIc=
Content-Language: en-US
In-Reply-To: <tnsu2g$85f$1@gioia.aioe.org>
 by: Chris M. Thomasson - Tue, 20 Dec 2022 20:52 UTC

On 12/20/2022 10:12 AM, Jame O' Brian wrote:
> On 20/12/2022 13:44, Kaz Kylheku wrote:
>> if (a + b > a
>
>
> Under what circumstances will ( a + b ) not greater than a? Example please.

Overflow.

Re: Increment/decrement a variable with a maximum

<644ff5b9-a628-466c-bfc6-7b4d73d9a7f3n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24082&group=comp.lang.c#24082

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:8c7:b0:3a9:89ac:3d32 with SMTP id i7-20020a05622a08c700b003a989ac3d32mr235619qte.518.1671801672102;
Fri, 23 Dec 2022 05:21:12 -0800 (PST)
X-Received: by 2002:a37:450:0:b0:6fe:d573:ad5f with SMTP id
77-20020a370450000000b006fed573ad5fmr455497qke.14.1671801671967; Fri, 23 Dec
2022 05:21:11 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 23 Dec 2022 05:21:11 -0800 (PST)
In-Reply-To: <tnt7ak$pcng$5@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=145.14.47.111; posting-account=pysjKgkAAACLegAdYDFznkqjgx_7vlUK
NNTP-Posting-Host: 145.14.47.111
References: <tno602$2cj2$1@dont-email.me> <20221220053840.192@kylheku.com>
<tnsu2g$85f$1@gioia.aioe.org> <tnt7ak$pcng$5@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <644ff5b9-a628-466c-bfc6-7b4d73d9a7f3n@googlegroups.com>
Subject: Re: Increment/decrement a variable with a maximum
From: oot...@hot.ee (Öö Tiib)
Injection-Date: Fri, 23 Dec 2022 13:21:12 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1493
 by: Öö Tiib - Fri, 23 Dec 2022 13:21 UTC

On Tuesday, 20 December 2022 at 22:52:51 UTC+2, Chris M. Thomasson wrote:
> On 12/20/2022 10:12 AM, Jame O' Brian wrote:
> > On 20/12/2022 13:44, Kaz Kylheku wrote:
> >> if (a + b > a
> >
> >
> > Under what circumstances will ( a + b ) not greater than a? Example please.
> Overflow.

Or when b is 0.

Re: Increment/decrement a variable with a maximum

<to5818$1rch0$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=24084&group=comp.lang.c#24084

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Increment/decrement a variable with a maximum
Date: Fri, 23 Dec 2022 13:53:43 -0800
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <to5818$1rch0$2@dont-email.me>
References: <tno602$2cj2$1@dont-email.me> <20221220053840.192@kylheku.com>
<tnsu2g$85f$1@gioia.aioe.org> <tnt7ak$pcng$5@dont-email.me>
<644ff5b9-a628-466c-bfc6-7b4d73d9a7f3n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 23 Dec 2022 21:53:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="9a9b36f82edd15ac437f8944c2ffb1eb";
logging-data="1946144"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Xg9+P9LoE+1J9D/EWX9J/X6t5r7xKNn4="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:sdqf2Pbo7U4qzWNGH/2d2pbtKdc=
Content-Language: en-US
In-Reply-To: <644ff5b9-a628-466c-bfc6-7b4d73d9a7f3n@googlegroups.com>
 by: Chris M. Thomasson - Fri, 23 Dec 2022 21:53 UTC

On 12/23/2022 5:21 AM, Öö Tiib wrote:
> On Tuesday, 20 December 2022 at 22:52:51 UTC+2, Chris M. Thomasson wrote:
>> On 12/20/2022 10:12 AM, Jame O' Brian wrote:
>>> On 20/12/2022 13:44, Kaz Kylheku wrote:
>>>> if (a + b > a
>>>
>>>
>>> Under what circumstances will ( a + b ) not greater than a? Example please.
>> Overflow.
>
> Or when b is 0.

Touche! I totally missed that case. Thanks.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor