Steve Hay wrote:

>This program
>
>#include <math.h>
>#include <stdio.h>
>void main(void) {
>  double x, y;
>  x = pow(9.0, 9.0);
>  printf("x = %lf\n", x);
>  y = pow(9.0, x);
>  printf("y = %lf\n", y);
>}
>
>outputs
>
>x = 387420489.000000
>
>pow: OVERFLOW error
>y = +INF
>
>when built with Borland, whereas VC++ and GCC both give me
>
>x = 387420489.000000
>y = 1.#INF00
>
>The OVERFLOW error (and the DOMAIN error seen in lib/warnings.t) are 
>presumably related to this enum in Borland's <math.h>
>
>typedef enum
>{
>    DOMAIN = 1,    /* argument domain error -- log (-1)        */
>    SING,          /* argument singularity  -- pow (0,-2))     */
>    OVERFLOW,      /* overflow range error  -- exp (1000)      */
>    UNDERFLOW,     /* underflow range error -- exp (-1000)     */
>    TLOSS,         /* total loss of significance -- sin(10e70) */
>    PLOSS,         /* partial loss of signif. -- not used      */
>    STACKFAULT     /* floating point unit stack overflow       */
>}   _mexcep;
>
>but I still see no way of disabling them yet. Still looking...
>
After a bit of Googling (since there is bugger all documentation with 
the free commandline tools download) I think I've found the answer.

Here's a useful link: http://www.clipx.net/ng/borcpp/ng42cd3.php

So the solution is to define a _matherr() function which returns 1 to 
indicate that it has handled the error, thus suppressing the stderr warning.

#include <math.h>
#include <stdio.h>
void main(void) {
  double x, y;
  x = pow(9.0, 9.0);
  printf("x = %lf\n", x);
  y = pow(9.0, x);
  printf("y = %lf\n", y);
}
int _matherr(struct _exception *a) {
  a->retval = a->retval;
  return 1;
}

This fixes the B/t/deparse.t error, and also the lib/warnings.t error 
now succeeds with change 24870 reverted.

So I've applied this (and reverted 24870) in change 24883.



------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are 
confidential and intended for the addressee(s) only.  If you have received this 
message in error or there are any problems, please notify the sender 
immediately.  The unauthorized use, disclosure, copying or alteration of this 
message is strictly forbidden.  Note that any views or opinions presented in 
this email are solely those of the author and do not necessarily represent 
those of Radan Computational Ltd.  The recipient(s) of this message should 
check it and any attached files for viruses: Radan Computational will accept no 
liability for any damage caused by any virus transmitted by this email.

Reply via email to