dc_frsingle()

Converts a single-precision floating point variable to a string for display in a field

Call
#include <vv_singl.h>
int dc_frsingle(stp, datap, dfldp, cvbufp)

UCHAR *stp

Pointer to a string buffer

PTR datap Pointer to data variable containing a float value
DFIELDPTR dfldp Pointer to a data field structure
PTR cvbufp Pointer to a data conversion buffer
Returns  
1 The single-precision floating point value was successfully converted to a string
0 A floating point string exists, but an error occurred. Either (1) the exponent portion of the string is larger than the field picture permits, or (2) the string is too large to fit in the field
Description

dc_frsingle() checks the field picture for the specified field to determine if the exponential format is being used and the number of decimal locations. Exponential notation is used if the value is too large or small to display without exponential notation, even if exponential notation is not specified in the field picture.

dc_frsingle() calls sprintf() to convert the single-precision floating point variable to a string using the appropriate notation and the correct number of decimal locations.

If exponential notation is used, the exponent portion of the string is converted to match the picture. Leading zeros are inserted, if necessary. If the exponent is larger than the field picture permits, dc_frsingle() returns a zero.

If thousands separators are specified (THSEPARATOR is ON for the field), they are inserted as needed into the mantissa. If inserting thousands separators makes the string too long to fit in the field, they are not inserted.

If right justification is set for the field (RTADJUST is ON), then the string is shifted to the right.

The string is checked to ensure that it fits in the field. If it doesn't fit, dc_frsingle() returns a zero.

Related Functions

dc_tosingle(), vf_single()

Cautions

dc_frsingle() assumes that the string buffer is large enough to hold the resulting string, including a null terminator '/0'.

This function calls sprintf(). You may have to link the appropriate floating point library to enable sprintf() to work with floating point variables.

A data conversion error is not considered a fatal error. VV_ERR does not get set; therefore, the VCS error reporting system does not report this condition.


Home Contents Previous Next