unittest::ToUnitTestPrecision - reduce argument to specified precision.
double integer ToUnitTestPrecision -> double or integer
array integer ToUnitTestPrecision -> array
other integer ToUnitTestPrecision -> other

7.83635342928 6 ToUnitTestPrecision --> 7.83635
-32.38763534 6 ToUnitTestPrecision --> -32.3876
(flower) 6 ToUnitTestPrecision --> (flower)
[7.83635342928 (flower) -32.38763534]
6 ToUnitTestPrecision --> [7.83635 (flower) -32.3876]
-70 6 ToUnitTestPrecision type --> /integertype
-70.0 6 ToUnitTestPrecision type --> /integertype

Reduces its double argument to the precision specified by the integer.
If the first argument is an array, ToUnitTestPrecision is recursively
applied to all elements of the array. Any other first argument is
returned unchanged. This is useful in processing heterogeneous arrays.
ToUnitTestPrecision uses a C++ output stream to carry out the reduction
of precision and manipulator setprecision() is used to set the precision.
The contents of the stream is converted back to a numerical object by
operator token. This guarantees that for the conversion from text to double
the same algorithm
is used for the argument of ToUnitTestPrecision and the reference data,
usually explicitly specified in the test file as an array.
The double argument may contain an integral value or be converted to and
integral value due to the required precision. In this case the output
operator of the stream may decide to represent the value as an integer,
i. e. without a decimal point, trailing zeros, or an exponent. This often
increases the readability of reference data arrays (see e.g. test_iaf). The
SLI interpreter function then returns an object of type integer.
The operators token and cvd use the same algorithm for converting text to
to a numerical value. However cvd always return a double.
ToUnitTestPrecision is not an efficient algorithm for rounding numerical
values. The idea rather is to have an algorithm which is guaranteed to be
compatible with the text stream output of a simulation.

Markus Diesmann  


SeeAlso: Source: