| |
|
| Formats |
PRECISION
num [ FOR OBJECT
]
Where:
| num |
Precision
to which to round. Numeric expression.
Integer range: 0 to 18, or use -1 to switch to
scientific notation. |
| FOR OBJECT |
Object
Oriented Programming (OOP) - Optional
keywords for setting the default PRECISION
for all subsequent method invocations within
the current object instance, except for those
that have CLASS definitions that specifically
declare a PRECISION to use (preserving
encapsulation). |
|
| |
|
| Description |
Use
the PRECISION directive to change the
number of digits ProvideX maintains to the right of the
decimal point. (Internally, ProvideX makes all
calculations using 14 digits of accuracy but when numeric
data is output the value is rounded and returned using
the number of digits set in the PRECISION
directive.) The
precision setting is also used in conjunction with the ROUND
directive. If rounding is enabled (default mode), values
assigned to variables through the LET directive
will be rounded to the PRECISION num
specified.
|
|
|
| *Note* |
Precision
is automatically reset to the value found in the PD
System parameter by the following directives: BEGIN,CLEAR,
END, LOAD, RESET,
STOP, RUN. It will be
set to two (2) by default by a START
directive. |
|
|
| |
The
FLOATINGPOINT directive overrides the PRECISION
directive. PRECISION -1 can also be used to to have
ProvideX switch to FLOATINGPOINT (scientific
notation). Use another numeric value in the PRECISION
directive (e.g., PRECISION 2) to cancel scientific
notation. In Object
Oriented Programming (OOP), PRECISION
is used to force a pre-defined precision setting for
objects. This sets the precision before each function and
restores precision upon exit from a function. For more
information, see Object Oriented Programming.
|
| |
|
| Examples |
0010 FOR A=0 TO 6
0020 PRECISION A
0030 PRINT 1/3,
0040 NEXT A
0050 PRINT "
DONE"; STOP
->RUN
0 0.3 0.33 0.333 0.3333
0.33333 0.333333 DONE
0060 PRECISION 7
0070 PRINT 1/3,
@(15),"PRECISION: ",TCB(14)
0080 BEGIN ! Resets
precision to 2
0090 PRINT 1/3,
@(15),"PRECISION: ",PRC
0100 END
->RUN
0.3333333 PRECISION: 7
0.33 PRECISION: 2
|