l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2001 Dec 30 17:02

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] detecting overflows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] detecting overflows

On Mon 12 Mar 01, 10:30 AM, Micah Cowan said: 
> On Mon, Mar 12, 2001 at 10:08:37AM -0800, Peter Jay Salzman wrote:
> Must you absolutely place the value into an int?
funny that you mention this.  it was my last thought before sending the
email.  i guess not.  but i was a little reluctant considering the pretty
intricate interdependencies of my variables.  and the program is
sufficiently large that i'm no longer intimately familiar with the details
of implementation.

i'm deathly afraid of introducing float f = 5/9 type of errors.

but i think you may be right.  the variable is actually a loop counter.
program ends when it reaches zero.   i guess there's no harm to let the
program end when it reaches zero or less.

although a loop of size 10^85 will be running for a bit longer than i want
it to.   ;)

> I might suggest that you check the floating point value against
> LONG_MAX *before* the assignment, which is an easy way to catch this.
yes, another good point.

> You might also look at the Arithmetic Operations section of the libc
> manual (texinfo), but I don't think that you can find a function or
> something to dectect overflow for integer assignments - you /can/ for
> operations which involve only floating point types.
i'll do that.  thanks!


LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.