Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

floatingpoint(3head) [opensolaris man page]

floatingpoint.h(3HEAD)						      Headers						    floatingpoint.h(3HEAD)

NAME
floatingpoint.h, floatingpoint - IEEE floating point definitions SYNOPSIS
#include <floatingpoint.h> DESCRIPTION
This file defines constants, types, and functions used to implement standard floating point according to ANSI/IEEE Std 754-1985. The func- tions are implemented in libc. The included header file <sys/ieeefp.h> defines certain types of interest to the kernel. IEEE Rounding Modes fp_direction_type The type of the IEEE rounding direction mode. Note: the order of enumeration varies according to hardware. fp_precision_type The type of the IEEE rounding precision mode, which only applies on systems that support extended precision such as machines based on the Intel 80387 FPU or the 80486. SIGFPE handling: sigfpe_code_type The type of a SIGFPE code. sigfpe_handler_type The type of a user-definable SIGFPE exception handler called to handle a particular SIGFPE code. SIGFPE_DEFAULT A macro indicating the default SIGFPE exception handling, namely to perform the exception handling specified by the user, if any, and otherwise to dump core using abort(3C). SIGFPE_IGNORE A macro indicating an alternate SIGFPE exception handling, namely to ignore and continue execution. SIGFPE_ABORT A macro indicating an alternate SIGFPE exception handling, namely to abort with a core dump. IEEE Exception Handling N_IEEE_EXCEPTION The number of distinct IEEE floating-point exceptions. fp_exception_type The type of the N_IEEE_EXCEPTION exceptions. Each exception is given a bit number. fp_exception_field_type The type intended to hold at least N_IEEE_EXCEPTION bits corresponding to the IEEE exceptions numbered by fp_exception_type. Thus fp_inexact corresponds to the least significant bit and fp_invalid to the fifth least significant bit. Note: some operations may set more than one exception. IEEE Formats and Classification single;extended;quadruple Definitions of IEEE formats. fp_class_type An enumeration of the various classes of IEEE values and symbols. IEEE Base Conversion The functions described under floating_to_decimal(3C) and decimal_to_floating(3C) satisfy not only the IEEE Standard, but also the stricter requirements of correct rounding for all arguments. DECIMAL_STRING_LENGTH The length of a decimal_string. decimal_string The digit buffer in a decimal_record. decimal_record The canonical form for representing an unpacked decimal floating-point number. decimal_form The type used to specify fixed or floating binary to decimal conversion. decimal_mode A struct that contains specifications for conversion between binary and decimal. decimal_string_form An enumeration of possible valid character strings representing floating-point numbers, infinities, or NaNs. FILES
/usr/include/sys/ieeefp.h SEE ALSO
abort(3C), decimal_to_floating(3C), econvert(3C), floating_to_decimal(3C), sigfpe(3C), string_to_decimal(3C), strtod(3C) SunOS 5.11 5 Mar 1993 floatingpoint.h(3HEAD)

Check Out this Related Man Page

sigfpe(3C)						   Standard C Library Functions 						sigfpe(3C)

NAME
sigfpe - signal handling for specific SIGFPE codes SYNOPSIS
#include <floatingpoint.h> #include <siginfo.h> sigfpe_handler_type sigfpe(sigfpe_code_type code, sigfpe_handler_type hdl); DESCRIPTION
The sigfpe() function allows signal handling to be specified for particular SIGFPE codes. A call to sigfpe() defines a new handler hdl for a particular SIGFPE code and returns the old handler as the value of the function sigfpe(). Normally handlers are specified as pointers to functions; the special cases SIGFPE_IGNORE, SIGFPE_ABORT, and SIGFPE_DEFAULT allow ignoring, dumping core using abort(3C), or default han- dling respectively. Default handling is to dump core using abort(3C). The code argument is usually one of the five IEEE754-related SIGFPE codes: FPE_FLTRES fp_inexact - floating-point inexact result FPE_FLTDIV fp_division - floating-point division by zero FPE_FLTUND fp_underflow - floating-point underflow FPE_FLTOVF fp_overflow - floating-point overflow FPE_FLTINV fp_invalid - floating-point invalid operation Three steps are required to intercept an IEEE754-related SIGFPE code with sigfpe(): 1. Set up a handler with sigfpe(). 2. Enable the relevant IEEE754 trapping capability in the hardware, perhaps by using assembly-language instructions. 3. Perform a floating-point operation that generates the intended IEEE754 exception. The sigfpe() function never changes floating-point hardware mode bits affecting IEEE754 trapping. No IEEE754-related SIGFPE signals will be generated unless those hardware mode bits are enabled. SIGFPE signals can be handled using sigfpe(), sigaction(2) or signal(3C). In a particular program, to avoid confusion, use only one of these interfaces to handle SIGFPE signals. EXAMPLES
Example 1 Example Of A User-Specified Signal Handler A user-specified signal handler might look like this: #include <floatingpoint.h> #include <siginfo.h> #include <ucontext.h> /* * The sample_handler prints out a message then commits suicide. */ void sample_handler(int sig, siginfo_t *sip, ucontext_t *uap) { char *label; switch (sip->si_code) { case FPE_FLTINV: label = "invalid operand"; break; case FPE_FLTRES: label = "inexact"; break; case FPE_FLTDIV: label = "division-by-zero"; break; case FPE_FLTUND: label = "underflow"; break; case FPE_FLTOVF: label = "overflow"; break; default: label = "???"; break; } fprintf(stderr, "FP exception %s (0x%x) occurred at address %p. ", label, sip->si_code, (void *) sip->si_addr); abort(); } and it might be set up like this: #include <floatingpoint.h> #include <siginfo.h> #include <ucontext.h> extern void sample_handler(int, siginfo_t *, ucontext_t *); main(void) { sigfpe_handler_type hdl, old_handler1, old_handler2; /* * save current fp_overflow and fp_invalid handlers; set the new * fp_overflow handler to sample_handler() and set the new * fp_invalid handler to SIGFPE_ABORT (abort on invalid) */ hdl = (sigfpe_handler_type) sample_handler; old_handler1 = sigfpe(FPE_FLTOVF, hdl); old_handler2 = sigfpe(FPE_FLTINV, SIGFPE_ABORT); ... /* * restore old fp_overflow and fp_invalid handlers */ sigfpe(FPE_FLTOVF, old_handler1); sigfpe(FPE_FLTINV, old_handler2); } FILES
/usr/include/floatingpoint.h /usr/include/siginfo.h ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
sigaction(2), abort(3C), signal(3C), attributes(5), floatingpoint.h(3HEAD) DIAGNOSTICS
The sigfpe() function returns (void(*)())-1 if code is not zero or a defined SIGFPE code. SunOS 5.11 4 May 2004 sigfpe(3C)
Man Page