Numerical overflow

P

Parachute

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.
 
A

Ancient_Hacker

Parachute said:
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.
 
P

Parachute

Ancient_Hacker said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top