Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c, sci.math.symbolic |
| Subject | Re: Test for overflow |
| Date | 2015-03-31 13:41 -0400 |
| Organization | Self |
| Message-ID | <551ADC38.4010704@verizon.net> (permalink) |
| References | <mfbbc6$9h9$3@speranza.aioe.org> <551985CA.7000409@verizon.net> <5519DFAA.40505@verizon.net> <mfdaal$s1j$1@speranza.aioe.org> |
Cross-posted to 2 groups.
On 03/31/2015 01:11 AM, jacob navia wrote:
> I hope this doesn't go into your kill file... Anyway
So far, you haven't used you new e-mail address to say anything that
made me want to to add it to my kill file.
> Now I will do
>
> maxvalNotOverflow = maxval/base;
>
> and then, at each step:
>
> if (value > maxvalNotOverflow) {
> digit = OVERFLOW_FLAG;
> break;
> }
> else value = value * base;
>
> Now, I DO believe that my test is OK when testing for an ADDITION overflow.
>
> if (value+digit < value) {
> digit = OVERFLOW_FLAG;
> break;
> }
> else value += digit;
>
> OK?
I think so, so long as 'digit' is no wider than 'value' - given the
context, if they were different sizes, I'd expect 'digit' to be smaller,
so that shouldn't be a problem. Of course, my judgement is more reliable
when I say there's a problem than when I say there's no problem.
> Note: ALL values are unsigned.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Test for overflow jacob navia <jacob@jacob.remcomp.fr> - 2015-03-30 13:17 +0200
Re: Test for overflow Lőrinczy Zsigmond <zsiga@nospam.for.me> - 2015-03-30 13:34 +0200
Re: Test for overflow Richard Damon <Richard@Damon-Family.org> - 2015-03-30 07:42 -0400
Re: Test for overflow asetofsymbols@gmail.com - 2015-03-30 04:47 -0700
Re: Test for overflow jacob navia <jacob@jacob.remcomp.fr> - 2015-03-30 13:57 +0200
Re: Test for overflow Richard Damon <Richard@Damon-Family.org> - 2015-03-30 08:24 -0400
Re: Test for overflow Richard Heathfield <rjh@cpax.org.uk> - 2015-03-30 13:03 +0100
Re: Test for overflow Tim Rentsch <txr@alumni.caltech.edu> - 2015-03-30 06:54 -0700
Re: Test for overflow James Kuyper <jameskuyper@verizon.net> - 2015-03-30 13:20 -0400
Re: Test for overflow James Kuyper <jameskuyper@verizon.net> - 2015-03-30 13:32 -0400
Re: Test for overflow James Kuyper <jameskuyper@verizon.net> - 2015-03-30 19:43 -0400
Re: Test for overflow jacob navia <jacob@jacob.remcomp.fr> - 2015-03-31 07:11 +0200
Re: Test for overflow James Kuyper <jameskuyper@verizon.net> - 2015-03-31 13:41 -0400
Re: Test for overflow jacob navia <jacob@jacob.remcomp.fr> - 2015-03-31 19:48 +0200
Re: Test for overflow James Kuyper <jameskuyper@verizon.net> - 2015-03-31 13:58 -0400
Re: Test for overflow Thomas Jahns <jahns@idontlikespam.dkrz.de> - 2015-04-01 10:12 +0200
Re: Test for overflow Richard Heathfield <rjh@cpax.org.uk> - 2015-04-01 09:43 +0100
Re: Test for overflow Thomas Jahns <jahns@idontlikespam.dkrz.de> - 2015-04-01 10:59 +0200
Re: Test for overflow Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-01 04:07 -0700
Re: Test for overflow raltbos@xs4all.nl (Richard Bos) - 2015-04-01 13:52 +0000
csiph-web