preload

Math primitives 1 (WinRunner, TSL)

Posted by Albert Gareev on Apr 15, 2007 | Categories: MathSource code

Service Functions – Math / WinRunner

Absolute value (Modulus)

public function mx_val_mod(in value) {
 if (value < 0)
  return(-1*value);
 else
  return(value); 
}

Check if a value has a multiple

public function mx_val_multiple(in value1, in value2) {
 auto k;
 if (value2 == 0) return(TRUE);

 k = value1 / value2;
 return(int(k) == k);
}

Check if a value belongs to range

public function mx_val_belongs(in value, in min, in max) {
 return((value >= min) && (value <= max)); 
}

Check if floating point values are equal in delta-range

public function mx_val_equ(in value1, in value2, in range) {
 auto rc;

 rc = mx_val_mod(mx_val_mod(value1) - mx_val_mod(value2));
 return(rc <= range);
}

Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.