l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social Gathering
Next Installfest:
TBD
Latest News:
Aug. 19: Siafoo slides and photos online
Page last updated:
2001 Dec 30 17:02
Events
 Meetings
 Installfests
 Demos
 Photos
Services
 Library
 LERT
 Jobs
 Documents
Interact
 Mailing Lists
 - Search
 - Archives
 Chat
About Us
 Members
 Projects
 Testimonials
 Call for Speakers
 Why Not MS?
 Finances
 Sponsors

^Home
?Search
?News & RSS
?Calendar
@Contact Us
$Buy Stuff
=Printable


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!

pete


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

CD Burns Wanted!

LUGOD: Linux Users' Group of Davis
1105 Kennedy Place, Suite 1, Davis, CA 95616
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:
Marc Hall
For a generous donation to allow us to continue meeting at the Davis Library.