Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - matherr http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   matherr

   Usage
   #include <math.h>
   int matherr(struct exception *e);

   Description
   matherr  is  called by functions in the math library when  errors  are
   detected.  Users  may  use the library supplied  matherr  function  or
   define  their  own  procedures  for handling  errors  by  including  a
   function named matherr in their programs. matherr must be of the  form
   described  above. A pointer to the exception structure will be  passed
   to the user supplied matherr function when errors occur. The structure
   is defined in <math.h> and matherr is available in the library  source
   for an example.

   Return Value
   A zero returned from matherr means error was handled correctly, a  one
   returned means the error could not be handled.

   Example
   #include <stdio.h>
   #include <math.h>
   #include <string.h>

   main()
   {
        printf("log(-1) = %e\n",log(-1));
   }

   int matherr(x)
   struct exception *x;
   {
        if(x->type == DOMAIN)
        {
             if(strcmp(x->name,"log") == 0)
             {
                  x->retval = log(-(x->arg1));
                  return(1);
            }
        }
        return(0);
   }


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson