matherr man page on Ultrix

Man page or keyword search:  
man Server   3690 pages
apropos Keyword Search (all sections)
Output format
Ultrix logo
[printable version]

matherr(3m)							   matherr(3m)

Name
       matherr - error-handling function for System V math library

Syntax
       #include <math.h>

       int matherr (x)
       struct exception ∗x;

Description
       The  subroutine	is  invoked  by functions in the System V Math Library
       when errors are detected.  Users may define their  own  procedures  for
       handling	 errors	 by including a function named in their programs.  The
       subroutine must be of the form  described  above.   A  pointer  to  the
       exception structure x will be passed to the user-supplied function when
       an error occurs.	 This structure, which	is  defined  in	 the  <math.h>
       header file, is as follows:
       struct exception {
	    int type;
	    char ∗name;
	    double arg1, arg2, retval;
       };

       The  element  type  is an integer describing the type of error that has
       occurred, from the following list of constants (defined in  the	header
       file):
       DOMAIN	  domain error
       SING	  singularity
       OVERFLOW	  overflow
       UNDERFLOW  underflow
       TLOSS	  total loss of significance
       PLOSS	  partial loss of significance

       The element name points to a string containing the name of the function
       that had the error.  The variables arg1 and arg2 are the	 arguments  to
       the  function  that  had	 the  error.   The  retval is a double that is
       returned by the function having the error.  If  it  supplies  a	return
       value,  the  user's must return nonzero.	 If the default error value is
       to be returned, the user's must return 0.

       If is not supplied by the user, the default error-handling  procedures,
       described with the math functions involved, will be invoked upon error.
       These procedures are also summarized in	the  table  below.   In	 every
       case, errno is set to nonzero and the program continues.

Examples
       matherr(x)
       register struct exception ∗x;
       {
	    switch (x->type) {
	    case DOMAIN:
	    case SING: /∗ print message and abort ∗/
		 fprintf(stderr, "domain error in %s\n", x->name);
		 abort( );
	    case OVERFLOW:
		 if (!strcmp("exp", x->name)) {
		      /∗ if exp, print message, return the argument ∗/
		      fprintf(stderr, "exp of %f\n", x->arg1);
		      x->retval = x->arg1;
		 } else if (!strcmp("sinh", x->name)) {
		      /∗ if sinh, set errno, return 0 ∗/
		      errno = ERANGE;
		      x->retval = 0;
		 } else
		      /∗ otherwise, return HUGE ∗/
		      x->retval = HUGE;
		 break;
	    case UNDERFLOW:
		 return (0); /∗ execute default procedure ∗/
	    case TLOSS:
	    case PLOSS:
		 /∗ print message and return 0 ∗/
		 fprintf(stderr, "loss of significance in %s\n", x->name);
		 x->retval = 0;
		 break;
	    }
	    return (1);
       }

┌────────────────────────────────────────────────────────────────────────────┐
│	       │      DEFAULT ERROR HANDLING PROCEDURES			     │
│	       │							     │
├──────────────┼───────────────┬───────┬──────────┬───────────┬───────┬──────┤
│	       Types of Errors │       │	  │	      │	      │	     │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│	       │   DOMAIN      │ SING  │OVERFLOW  │UNDERFLOW  │TLOSS  │PLOSS │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│BESSEL:       │      -	       │  -    │    H	  │    0      │ M, 0  │	 ∗   │
│y0, y1, yn    │   M, -H       │  -    │    -	  │    -      │	 -    │	 -   │
│ (neg. no.)   │	       │       │	  │	      │	      │	     │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│EXP:	       │      -	       │  -    │    H	  │    0      │	 -    │	     │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│POW:	       │      -	       │  -    │    H	  │    0      │	 -    │	 -   │
│(neg.)∗∗(non- │    M, 0       │  -    │    -	  │    -      │	 -    │	 -   │
│ int.), 0∗∗0  │	       │       │	  │	      │	      │	     │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│LOG:	       │	       │       │	  │	      │	      │	     │
│log(0):       │      -	       │M, -H  │    -	  │    -      │	 -    │	 -   │
│log(neg.):    │    M, -H      │  -    │    -	  │    -      │	 -    │	 -   │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│SQRT:	       │    M, 0       │  -    │    -	  │    -      │	 -    │	 -   │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│GAMMA:	       │      -	       │ M, H  │    -	  │    -      │	 -    │	 -   │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│HYPOT:	       │      -	       │  -    │    H	  │    -      │	 -    │	 -   │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│SINH, COSH:   │      -	       │  -    │    H	  │    -      │	 -    │	 -   │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│SIN, COS:     │      -	       │  -    │    -	  │    -      │ M, 0  │	 ∗   │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│TAN:	       │      -	       │  -    │    H	  │    -      │ M, 0  │	 ∗   │
├──────────────┼───────────────┼───────┼──────────┼───────────┼───────┼──────┤
│ACOS, ASIN:   │    M, 0       │  -    │    -	  │    -      │	 -    │	 -   │
└──────────────┴───────────────┴───────┴──────────┴───────────┴───────┴──────┘
       ┌────────────────────────────────────────────────────┐
       │		   ABBREVIATIONS		    │
       │ ∗    As much as possible of the value is returned. │
       │ M    Message is printed.			    │
       │ H    HUGE is returned.				    │
       │ -H   -HUGE is returned.			    │
       │ 0    0 is returned.				    │
       └────────────────────────────────────────────────────┘

				      VAX			   matherr(3m)
[top]

List of man pages available for Ultrix

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
...................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net