Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: mathog@seqaxp.bio.caltech.edu
Subject: Re: Division by zero crashes on DEC should be avoidable!
Date: 1998/03/06	[thread overview]
Message-ID: <6dpdce$jsg@gap.cco.caltech.edu> (raw)
In-Reply-To: 34FF7719.41C6@ned.dem.csiro.au


In article <34FF7719.41C6@ned.dem.csiro.au>, Andrew Ellerton <andrewe@ned.dem.csiro.au> writes:
>Dear All,
>
>This is possibly a simple question:
>
>	On other UNIX platforms the application I have to port
>	to DEC works fine - including handling division by zero
>	with only a warning, presumably using not-a-number (NaN)
>	or INF symbols as the result. Sure, I know it should 
>	never try to divide by zero, but it does.
>
>	However, the C++ code will crash the entire application
>	on the DEC 4.0 version when it divides by zero. Is this
>	solvable by (for example) compiling with a certain switch? 
>

For the OpenVMS version of DEC C++ there is a /IEEE_MODE, the HELP for it
says:

CXX

  /IEEE_MODE=option


     Selects the IEEE floating-point mode to be used if /FLOAT=IEEE_FLOAT
     is specified. You can select from the following options:

     FAST               During program execution, only finite values (no
                        infinities, NaNs, or denorms) are created.
                        Exceptional conditions, such as floating-point
                        overflow and divide-by-zero, are fatal. This is
                        the default option.

     UNDERFLOW_TO_ZERO  Generate infinities and NaNs. Flush denormalized
                    results and underflow to zero without exceptions.

     DENORM_RESULTS     Same as UNDERFLOW_TO_ZERO, except that denorms are
                    generated.

     INEXACT            Same as DENORM_RESULTS, except that inexact values
                    are trapped. This is the slowest mode.

     The default is /IEEE_MODE=FAST.

So, try something like -IEEE_MODE=UNDERFLOW_TO_ZERO (syntax is almost certainly 
different than that given here.)

>	Or is there any other way to stop it from crashing, or do
>	I have to resort to modifying the code? 

I consider think that it is a very bad idea to depend on your compiler having a
mode which will enable it to ignore invalid operation results (divide by zero).
(Except in languages with try/trap methods built into the standard.) Ok, so you
find the right switch, and the program no longer crashes at this illegal
operation, but what did it do with the resulting value? It runs to completion,
but is the answer correct??? 

Regards,

David Mathog
mathog@seqaxp.bio.caltech.edu
Manager, sequence analysis facility, biology division, Caltech 
**************************************************************************
*   Affordable VMS? See:  http://seqaxp.bio.caltech.edu/www/pcvms.html   *
**************************************************************************



  parent reply	other threads:[~1998-03-06  5:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-03-06  5:00 Division by zero crashes on DEC should be avoidable! Andrew Ellerton
1998-03-06  5:00 ` Ron Natalie
1998-03-06  5:00 ` Daniel S. Riley
1998-03-06  5:00 ` mathog [this message]
1998-03-06  5:00   ` Michael C. Grant
1998-03-06  5:00     ` Pierre Asselin
1998-03-08  5:00       ` Michael C. Grant
1998-03-06  5:00 ` Dag-Erling Coidan Sm�rgrav
1998-03-06  5:00   ` John Wilson
1998-03-06  5:00   ` Michael C. Grant
1998-03-06  5:00     ` Jeffrey J. Potoff
1998-03-09  5:00     ` Dan A. Mercer
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox