11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

PRECISION<br />

Syntax<br />

PRECISION num.expr<br />

Description<br />

The <strong>UniBasic</strong> PRECISION command rounds numbers to the number of decimal<br />

places indicated in num.expr. num.expr can be a number from 0 to 14. If the number<br />

is not within this range, UniData does not change the setting. The default is four<br />

decimal places.<br />

Tip: UniData converts the operands in numeric operations from string to numeric<br />

data type, performs the operations, and then converts the results back to string data<br />

type. When making calculations for which you require a high degree of precision, use<br />

the PRECISION command to force UniData to represent a particular level of decimal<br />

representation.<br />

Set the UniData FLOAT.PRECISION to 4 to truncate rather than round at the<br />

PRECISION setting.<br />

Examples<br />

In the following example, the program statement results in all numeric variables<br />

being truncated to eight decimal places:<br />

PRECISION 8<br />

In the next example, the program statement truncates all digits to the right of the<br />

decimal point:<br />

PRECISION 0<br />

In the next example, the program statement sets precision based on the variable DEC:<br />

PRECISION DEC<br />

PRECISION 1-570

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!