Field-Map Scripting

4.1.3.1.34 CompareValue

CompareValue function



Prototype:

function CompareValue (const A, B :Double; Epsilon :Double  0) :integer;

Description:

The CompareValue compares the numbers A and B in a tolerant way. If the numbers A and B close to each other are considered to be equal. The parameter Epsilon is the permissible tolerance.

Syntax:

CompareValue(A, B, Epsilon); / variable:= CompareValue(A, B, Epsilon);


Part

Description


variable

A variable declared as integer


A

A parameter declared as double to compare


B

A parameter declared as double to compare


Epsilon

A parameter declared as double, this is a tolerance between numbers A and B

Return value:

 0 ... if numbers A and B is equal ... A=B

-1 ... if A is less than B ...               A<B

 1 ... if A is bigger than B ...            A>B





Example:


var

 a,b : double;

 epsilon : double;

 x : integer;


begin

 a:= 2.15;

 b:= 2.14;

 epsilon:= 0.001;

 x:= CompareValue(a,b, epsilon);

 ShowMessage(IntToStr(x));

end.

// Next examples: CompareValue(2.1, 2.2, 0)   = -1

//                CompareValue(2.3, 2.1, 0.1) =  1

//                CompareValue(2.1, 2.3, 0.2) =  0



Output in Field-Map Data Collector:


See also:

Power; Round; RoundTo, RoundVariant; Round2int, Cos; ArcCos; ArcCosH; Sin; ArcSin; ArcSinH; ArcTan; ArcTan2; ArcTanH; CosH; SinH; Tan; TanH; Random; RandomRange; Randomize; Floor; Ceil; Int; Frac; Log10; Ln; Exp; Abs; Min; Max; Odd; SecondsBetween;CompareValue; SameValue; Trunc


Example