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