1*61306Sbostic.\" Copyright (c) 1985, 1991, 1993 2*61306Sbostic.\" The Regents of the University of California. All rights reserved. 324693Smckusick.\" 448352Scael.\" %sccs.include.redist.man% 524693Smckusick.\" 6*61306Sbostic.\" @(#)infnan.3 8.1 (Berkeley) 06/04/93 748352Scael.\" 848352Scael.Dd 948352Scael.Dt INFNAN 3 1048352Scael.Os BSD 4.3 1148352Scael.Sh NAME 1248352Scael.Nm infnan 1348352Scael.Nd signals invalid floating\-point operations on a 1448352Scael.Tn VAX 1548352Scael(temporary) 1648352Scael.Sh SYNOPSIS 1748352Scael.Fd #include <math.h> 1848352Scael.Ft double 1948352Scael.Fn infnan "int iarg" 2048352Scael.Sh DESCRIPTION 2124379SmiriamAt some time in the future, some of the useful properties of 2248352Scaelthe Infinities and \*(Nas in the 2348352Scael.Tn IEEE 2448352Scaelstandard 754 for Binary 2548352ScaelFloating\-Point Arithmetic will be simulated in 2648352Scael.Tn UNIX 2748352Scaelon the 2848352Scael.Tn DEC VAX 2948352Scaelby using its Reserved Operands. Meanwhile, the 3024379SmiriamInvalid, Overflow and Divide\-by\-Zero exceptions of the 3148352Scael.Tn IEEE 3248352Scaelstandard are being approximated on a 3348352Scael.Tn VAX 3448352Scaelby calls to a 3548352Scaelprocedure 3648352Scael.Fn infnan 3748352Scaelin appropriate places in 3848352Scael.Xr libm 3 . 3948352ScaelWhen 4048352Scaelbetter exception\-handling is implemented in 4148352Scael.Tn UNIX , 4248352Scaelonly 4348352Scael.Fn infnan 4448352Scaelamong the codes in 4548352Scael.Xr libm 4648352Scaelwill have to be changed. 4748352ScaelAnd users of 4848352Scael.Xr libm 4948352Scaelcan design their own 5048352Scael.Fn infnan 5148352Scaelnow to 5224379Smiriaminsulate themselves from future changes. 5348352Scael.Pp 5448352ScaelWhenever an elementary function code in 5548352Scael.Xr libm 5648352Scaelhas to 5748352Scaelsimulate one of the aforementioned 5848352Scael.Tn IEEE 5948352Scaelexceptions, it calls 6048352Scael.Fn infnan iarg 6148352Scaelwith an appropriate value of 6248352Scael.Fa iarg . 6348352ScaelThen a 6448352Scaelreserved operand fault stops computation. But 6548352Scael.Fn infnan 6648352Scaelcould 6724379Smiriambe replaced by a function with the same name that returns 6824379Smiriamsome plausible value, assigns an apt value to the global 6948352Scaelvariable 7048352Scael.Va errno , 7148352Scaeland allows computation to resume. 7224379SmiriamAlternatively, the Reserved Operand Fault Handler could be 7328819Skjdchanged to respond by returning that plausible value, etc. 7424379Smiriaminstead of aborting. 7548352Scael.Pp 7624379SmiriamIn the table below, the first two columns show various 7748352Scaelexceptions signaled by the 7848352Scael.Tn IEEE 7948352Scaelstandard, and the default 8024379Smiriamresult it prescribes. The third column shows what value is 8148352Scaelgiven to 8248352Scael.Fa iarg 8348352Scaelby functions in 8448352Scael.Xr libm 8548352Scaelwhen they 8648352Scaelinvoke 8748352Scael.Fn infnan iarg 8848352Scaelunder analogous circumstances on a 8948352Scael.Tn VAX . 9048352ScaelCurrently 9148352Scael.Fn infnan 9248352Scaelstops computation under all those 9324379Smiriamcircumstances. The last two columns offer an alternative; 9448352Scaelthey suggest a setting for 9548352Scael.Va errno 9648352Scaeland a value for a 9748352Scaelrevised 9848352Scael.Fn infnan 9948352Scaelto return. And a C program to 10024379Smiriamimplement that suggestion follows. 10124379Smiriam.sp 0.5 10248352Scael.Bd -filled -offset indent 10348352Scael.Bl -column "IEEE Signal" "IEEE Default" XXERANGE ERANGEXXorXXEDOM 10448352Scael.It IEEE Signal IEEE Default Ta 10548352Scael.Fa iarg Ta 10648352Scael.Va errno Ta 10748352Scael.Fn infnan 10848352Scael.It Invalid \*(Na Ta 10948352Scael.Dv EDOM EDOM 0 11048352Scael.It Overflow \(+-\*(If Ta 11148352Scael.Dv ERANGE ERANGE HUGE 11248352Scael.It Div\-by\-0 \(+-Infinity Ta 11348352Scael.Dv \(+-ERANGE ERANGE or EDOM \(+-HUGE 11448352Scael.It ( Ns Dv HUGE No "= 1.7e38 ... nearly 2.0**127)" 11548352Scael.El 11648352Scael.Ed 11748352Scael.Pp 11848352ScaelALTERNATIVE 11948352Scael.Fn infnan : 12048352Scael.Bd -literal -offset indent 12124379Smiriam#include <math.h> 12224379Smiriam#include <errno.h> 12324379Smiriamextern int errno ; 12424379Smiriamdouble infnan(iarg) 12524379Smiriamint iarg ; 12624379Smiriam{ 12724379Smiriam switch(iarg) { 12848352Scael case \0ERANGE: errno = ERANGE; return(HUGE); 12924379Smiriam case \-ERANGE: errno = EDOM; return(\-HUGE); 13024379Smiriam default: errno = EDOM; return(0); 13124379Smiriam } 13248352Scael} 13348352Scael.Ed 13448352Scael.Sh SEE ALSO 13548352Scael.Xr math 3 , 13648352Scael.Xr intro 2 , 13748352Scael.Xr signal 3 . 13848352Scael.Pp 13948352Scael.Dv ERANGE 14048352Scaeland 14148352Scael.Dv EDOM 14248352Scaelare defined in 14348352Scael.Aq Pa errno.h . 14448352Scael(See 14548352Scael.Xr intro 2 14648352Scaelfor explanation of 14748352Scael.Dv EDOM 14848352Scaeland 14948352Scael.Dv ERANGE . ) 15048352Scael.Sh HISTORY 15148352ScaelThe 15248352Scael.Fn infnan 15348352Scaelfunction appeared in 15448352Scael.Bx 4.3 . 155