Server for Information Technologies ������ ��������������
������� �������������� ����������
(095) 932-9212, 932-9213, 939-0783
E-mail: [email protected]
������ �������� ����(!) ������������� ���������� CIT Forum CD-ROM

MATHERR(3M)

��������
matherr - ������� ��������� ������

���������

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

��������
������� matherr ���������� ��������� �� �������������� ���������� ��� ����������� ������. ������������ ����� ���������� ����������� ��������� ��������� ������, ������� � ���� ��������� ������� � ������ matherr. ������� matherr ������ ����� ��������� ���� ���. ��� ������������� ������ ��������� x �� ��������� exception ����� ������� ������������� ������������� ������� matherr. ��� ���������, ������������ �� ���������� ���- �� <math.h>, ����� ��������� ���:

	struct exception {
	  int type;
	  char *name;
	  double arg1, arg2, retval;
	};
������� type ������������ ����� ����� �����, ��������- ��� ��� ����������� ������, �� ���������� ������ ����- ���� (������������ �� ���������� �����):
DOMAIN ����� �� ������� ������� �����������.
SING ��������� ��������� � ����� �������������.
OVERFLOW ������������.
UNDERFLOW ������������ �������.
TLOSS ������ ������ �������� ����.
PLOSS ��������� ������ �������� ����.
������� name ��������� �� ������� ��������, ���������� ��� �������, ��� ��������� � ������� ��������� ������. ���������� arg1 � arg2 �������� �������� ���������� ��� ������ �������. ���� retval ��������� ��������, ������� ����� ���������� �������� �� ���������, �� ���� � ��� ������, ���� ���������������� ������� matherr �� ����- ���� �� ����� ��������. ���� ���������������� ������� matherr ���������� ����- ����� ��������, �� �� ����� ���������� ��������� �� ������ � �� ����� ��������������� �������� ���������� errno. ���� ������� matherr ������������� �� �������������, �� ��� ������������� ������ �� ��������� ����� ���������� ���������, ��������� ������ � ���������������� ������- ��������� ���������. �������� �� ���� ���������� �� - ������� � �������, ���������� �����. � ������ ������ ���������� errno ������������� �������� EDOM ���� ERANGE � ���������� ��������� ������������.

������

	#include <math.h>
	int
	matherr (x)
	register struct exception *x;
	{
	  switch (x->type) {
	  case DOMAIN:
	    /* ������� �������� sqrt(-arg1) ������ 0 */
	    if (!strcmp(x->name, "sqrt")) {
	      x->retval=sqrt(-x->arg1);
	      return(0); /* ������ �����., �����. errno */
	    }
	  case SING:
	    /* ��� ��������� DOMAIN � SING ������:
	       ������ ��������� � ���������� ���������� */
	    fprintf(stderr,"���.����������� � %s\n",x->name);
	    abort();
	  case PLOSS:
	    /* ������ ��������� ��������� �� ������ */
	    fprintf(stderr,"������ ����.���� � %s(%g)=%g\n",
	             x->name,x->arg1,x->retval);
	    return(1); /* ������ ������� �������� */
	  }
	  return(0); /* ��������� ������ - �� ��������� */
	}

��������������� ��������� ��������� ������
���� ������
��� DOMAIN SING OVERFLOW UNDERFLOW TLOSS
errno EDOM EDOM ERANGE ERANGE ERANGE
BESSEL: - - - - M,0
y0,y1,yn (���<=0)M,-H----
EXP: - - H 0 -
LOG, LOG10:
(���<0) M,-H - - - -
(���=0) - M,-H - - -
POW:
(��� ** �����) - - +/-H 0 -
(0 ** �������) M,0 - - - -
SQRT: M,0 - - - -
GAMMA: - M,H H - -
HYPOT: - - H - -
SINH: - - +/-H - -
COSH: - - H - -
SIN, COS, TAN: - - - - M,0
ASIN, ACOS, ATAN2: M,0 - - - -

����������:
* �������� ������������ �� ����� ������������ ��������� �������
M �������� ��������� (������ EDOM)
H ������������ HUGE
-H ������������ -HUGE
+/-H ������������ HUGE ��� -HUGE
0 ������������ 0
Comments: [email protected]
Designed by Andrey Novikov
Copyright © CIT