Numerical overflow

Discussion in 'C Programming' started by Parachute, Aug 15, 2006.

  1. Parachute

    Parachute Guest

    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.
    Parachute, Aug 15, 2006
    #1
    1. Advertising

  2. 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.
    Ancient_Hacker, Aug 15, 2006
    #2
    1. Advertising

  3. Parachute

    Parachute Guest

    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
    Parachute, Aug 15, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. iMonkey

    Numerical Order

    iMonkey, Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    355
    iMonkey
    Jul 31, 2003
  2. Al Murphy

    Java numerical recipes online...

    Al Murphy, Feb 5, 2004, in forum: Java
    Replies:
    1
    Views:
    5,628
    Steve W. Jackson
    Feb 5, 2004
  3. Replies:
    4
    Views:
    515
    Roedy Green
    Mar 30, 2006
  4. Replies:
    1
    Views:
    335
    Johannes Koch
    Oct 11, 2005
  5. Parachute

    Numerical overflow

    Parachute, Aug 14, 2006, in forum: C++
    Replies:
    10
    Views:
    574
    Parachute
    Aug 15, 2006
Loading...

Share This Page