468,513 Members | 1,766 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

Numerical overflow

Using Borland Builder 6, I get numerical overflow when running a small
programme without CodeGuard ("exp: OVERFLOW error"). The programme does
not give any error messages when CodeGuard is activated during the run.
The equation that causes overflow uses the exp-function, but given and
resulting values are not very large. So why does it seem as if there
were not enough space in the buffer? And why doesn't the problem occur,
when the same programme is run with an activated CodeGuard?

The equation looks like this (except int delta_t: all variables
double):
new_amount = old_amount * ( 1 - ( A * exp(K1* delta_t) + (1-A) *
exp(K2* delta_t) ) );

The values of the parameters are:
A: between 0 and 0.6
K1: between -10^(-1) and -10^(-4)
K2: between -3 and -10(-5)
delta_t: 1 to possibly several hundred, but the programme never reaches
the point where large values of delta_t would occur.

The problem is not caused by data types: it also comes when all
variables and the constant 1 are double. Overflow occurs over the whole
range of parameter values. The error message can be clicked away, the
programme will then continue. But since the equation is written within
a loop, the error will come back repeatedly, finally causing the
programme to crash.

Aug 15 '06 #1
2 4414

Parachute wrote:
Using Borland Builder 6, I get numerical overflow when running a small
programme without CodeGuard ("exp: OVERFLOW error"). The programme does
not give any error messages when CodeGuard is activated during the run.
The equation that causes overflow uses the exp-function, but given and
resulting values are not very large. So why does it seem as if there
were not enough space in the buffer? And why doesn't the problem occur,
when the same programme is run with an activated CodeGuard?
try breaking down the expression into at least three separate
assignment statements, then print out the values.

ALso write your own exp() function wrapper, and print out the incoming
and outgoing values.

Aug 15 '06 #2

Ancient_Hacker schrieb:
Parachute wrote:
Using Borland Builder 6, I get numerical overflow when running a small
programme without CodeGuard ("exp: OVERFLOW error"). The programme does
not give any error messages when CodeGuard is activated during the run.
The equation that causes overflow uses the exp-function, but given and
resulting values are not very large. So why does it seem as if there
were not enough space in the buffer? And why doesn't the problem occur,
when the same programme is run with an activated CodeGuard?

try breaking down the expression into at least three separate
assignment statements, then print out the values.

ALso write your own exp() function wrapper, and print out the incoming
and outgoing values.
I've found the mistake: it lay in the time-variable, which regularly
took very strange values due to an incorrect use of dynamic memory
allocation before assigning the new time-value to the variable. So, the
root of the problem lay quite far away from its emergence...

Many thanks for your help!
Heidrun

Aug 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Rob Miller | last post: by
9 posts views Thread by Carl | last post: by
81 posts views Thread by Jonas Smithson | last post: by
16 posts views Thread by Martin Jørgensen | last post: by
23 posts views Thread by Abhi | last post: by
10 posts views Thread by Parachute | last post: by
42 posts views Thread by thomas.mertes | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.