Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cvtnum(3C) — HP-UX 6.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

scanf(3S)

strtod(3C)

strtol(3C)

CVTNUM(3C)

Series 300 Only

NAME

cvtnum − convert string to floating point number

SYNOPSIS

#include <cvtnum.h>

int cvtnum(src,dst,typ,rnd,ptr,inx)
unsigned char *src,*dst,**ptr;
int typ,rnd,*inx;

DESCRIPTION

The function 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 sign followed by a string of digits optionally containing a decimal point. It may 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 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 68881 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 may 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 and 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 will use this to return an indication of the inexactness of the conversion.  A zero indicates exact; a non-zero value, inexact. 

SEE ALSO

scanf(3S), strtod(3C), strtol(3C)
MC68881 Floating-Point Coprocessor User’s Manual

DIAGNOSTICS

If no errors occur or no non-standard conversions are done, cvtnum returns 0. Otherwise, it will return 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

Hewlett-Packard Company  —  May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026