Discussions

EJB design: underflow exception

  1. underflow exception (1 messages)

    i am working on a project which gets live data from telemeters and meter readings, and lot of processing is done using those data. at some places i am encountering Underflow Exception, and program terminates abruptly, is there any way to check the exception.......??
  2. underflow exception[ Go to top ]

    i am working on a project which gets live data from telemeters and meter readings, and lot of processing is done using those data. at some places i am encountering Underflow Exception, and program terminates abruptly, is there any way to check the exception.......??

    Hey,<br>
    The underflow exception occurs if the rounded result has an exponent that is too small to be represented using the floating-point format of the result.

    <br><br>

    Actually its very simple...
    <br>
    Surround the code which gets data or the code part which generates underflow exception in try-catch block
    In catch block assing variable(s) value zero , smallest normal number or a denormal number
    ;-)
    Eg. if code is

     float veryless=i-j; //here veryless generates underflow exc

      replace it by
      
    float veryless=0;
    try
    {
    veryless=i-j;
    }
    catch(Exception e) //or catch(Underflow e)
    {
    veryless=0; //or by some default
    }


    Bye,<br>
    Sanket Raut