cfunc.precision

C Function/C Functions, Releases: AP 6.1

Pick/BASIC 'precision' functionality from C.

Syntax

void _CP_precision(int number)

Description

equivalent to the Pick/BASIC statement: precision number.

This function affects the precision of the _CP_rs_ and the _CP_sr_ functions.

Example

CPSTR * s = _CP_mkstr('1.12345');
double r;

_CP_precision(2);
r = _CP_sr_(s);
_CP_unix_env();
printf('%g\n', r);
_CP_str_free(s);

This example displays '1.12' since the conversion is truncated to
the precision of 2.

See Also

Command Name Type Description
cfunc.introduction Introductory Overview
cfunc.rs C Function real to string conversion
cfunc.sr C Function converts a CPSTR into a double float number.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.