By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,212 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,212 IT Pros & Developers. It's quick & easy.

Numerical overflow

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a

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

P: n/a

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.