Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Numerical overflow

Reply
Thread Tools

Numerical overflow

 
 
Parachute
Guest
Posts: n/a
 
      08-15-2006
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.

 
Reply With Quote
 
 
 
 
Ancient_Hacker
Guest
Posts: n/a
 
      08-15-2006

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.

 
Reply With Quote
 
 
 
 
Parachute
Guest
Posts: n/a
 
      08-15-2006

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Numerical overflow Parachute C++ 10 08-15-2006 05:53 PM
How to read numerical data files stocksami@earthlink.net Java 4 03-30-2006 08:16 PM
Java numerical recipes online... Al Murphy Java 1 02-05-2004 06:14 PM
New Numerical Score Report for MCP Exams?! Martin Schmid Microsoft Certification 0 10-09-2003 11:48 AM
Numerical Order iMonkey ASP .Net 0 07-31-2003 02:43 PM



Advertisments