dc_frdouble()

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

Call  
#include <vv_doubl.h>
int dc_frdouble(stp, datap, dfldp, cvbufp)

UCHAR *stp

Pointer to a string buffer

PTR datap Pointer to data variable containing a double value
DFIELDPTR dfldp Pointer to a data field structure
PTR cvbufp Pointer to a data conversion buffer
Returns  
1 The double-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_double() 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_frdouble() calls sprintf() to convert the double-precision floating point variable to a string using the appropriate notation and the correct number of decimal places.

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

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_frdouble() returns a zero.

If BLANKONZERO is ON and the value is zero, the returned string will only contain a hard decimal point. All other characters will have been replaced with spaces.

Related Functions

dc_todouble(), vf_double()

Cautions

The data type must be double, not float.

dc_frdouble() 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