CompareWithPrecision

IVI Library

Ivi_CompareWithPrecision

Usage

ViStatus Ivi_CompareWithPrecision(ViInt32 digitsofPrecision, ViReal64 a, ViReal64 b, ViInt32* result);

Purpose

This function compares two ViReal64 values using the number of decimal digits of precision you specify.

If the two values are not exactly equal, the function uses the following logic, where a and b are the values you want to compare, and d is the digits of precision you specify.

if a == 0
  -(d-1)
if |b| < 10  then a == b.

else /* a != 0 */

   |a-b|     -(d-1)
if ----- < 10    then a == b
    |a|

The function returns the following values.

 0  if a == b
-1  if a < b
 1  if a > b

Parameters

Name Type Description
digitsofPrecision ViInt32

Specify the number of decimal digits of precision you want to use to compare the two ViReal64 values.

Valid Range: 0, or 1 to 14

If you pass 0, the function sets the precision to the IVI default for this value, which is 14.

a ViReal64

Specify the first value you want to compare.

b ViReal64

Specify the second value you want to compare.

result ViInt32*

Returns the results of the comparison.

Return values:
 0 (if a == b)
 1 (if a > b)
-1 (if a < b)

Return Value

Contains the status code that the function call returns. IVI engine functions can return error and warning values from several sets of status codes. Some status codes are unique to the IVI engine. Other status codes are the same codes that VISA Library functions return. Still others are error or warning values that functions in specific instrument drivers return. Each set of status codes has its own numeric range.

Regardless of the source of the status code, 0 always indicates success, a positive value indicates a warning, and a negative value indicates an error.

Related Topic

IVI Status Codes