cvtnum(3C) — Series 300/400 Only
NAME
cvtnum() − convert string to floating point number
SYNOPSIS
#include <cvtnum.h>
int cvtnum(
const unsigned char *src,
unsigned char *dst,
int typ,
int rnd,
unsigned char **ptr,
int *inx
);
DESCRIPTION
cvtnum() converts an ASCII character string to a number in one of four floating-point formats: single precision, double precision, extended precision, or packed decimal string.
The string pointed to by src is the string representation of a standard number, an infinity, or a not-a-number. A standard number begins with an optional plus or minus sign followed by a string of digits optionally containing a decimal point. It can then have an optional e or E followed by an optional sign followed by an integer. Infinities are represented by INF preceded by an optional plus or minus sign. The string for a not-a-number is an optional sign followed by NaN followed by any number of hexadecimal digits enclosed in parentheses.
The result is moved to dst and will be of the size and format as defined for the MC68881 floating-point coprocessor.
typ indicates the type of conversion to be done. It may be one of four values: C_SNGL, C_DBLE, C_EXT, or C_DPACK, indicating single precision, double precision, extended precision and packed decimal string, respectively.
rnd specifies the type of rounding mode and can be one of four values: C_NEAR, C_POS_INF, C_NEG_INF, or C_TOZERO, indicating round to nearest, to positive infinity, to negative infinity, or to zero, respectively.
If the value of *ptr is not (char ∗∗) NULL, a pointer to the character terminating the scan is returned in the location pointed to by ptr. If no number can be formed, *ptr is set to str.
If inx is not (int ∗) NULL, cvtnum() uses this to return an indication of the inexactness of the conversion. A zero indicates exact; a non-zero value, inexact.
RETURN VALUE
If no errors occur or no non-standard conversions are done, cvtnum() returns 0. Otherwise, it returns one of the following:
[C_BADCHAR] Illegal character or unexpected end of string
[C_OVER] Overflow
[C_UNDER] Underflow
[C_INF] Infinity
[C_QNAN] Quiet NaN
[C_SNAN] Signalling NaN
cvtnum() does not use errno when reporting errors.
SEE ALSO
scanf(3S), strtod(3C), strtol(3C).
MC68881 Floating-Point Coprocessor User’s Manual.
Hewlett-Packard Company — HP-UX Release 9.0: August 1992