result = isEqual(r1, r2); result = isEqual(r1, r2, eps=0.0);
The function call "isEqual(r1, r2)
" returns true,
if the two Real numbers r1 and r2 are the same up to a given precision eps.
(result = abs(r1-r2) ≤ eps). Otherwise the function
returns false. With the optional third argument eps
the range can be defined, in which two Real numbers are treated as identical.
The default is "eps = 0". Another useful value is, e.g.,
"eps = 10*Modelica.Constants.eps".
Real r1 = 3; Real r2 = 3; Real r3 = 3.0001; Boolean result; algorithm result := isEqual(r1,r2); // = true result := isEqual(r1,r3); // = false result := isEqual(r1,r3, eps=0.1); // = true
Modelica.Math.Vectors.isEqual, Modelica.Math.Matrices.isEqual, Modelica.Utilities.Strings.isEqual
function isEqual extends Modelica.Icons.Function; input Real u1 "First scalar"; input Real u2 "Second scalar"; input Real eps(min = 0) = 0.0 "The two scalars are identical if abs(u1-u2) <= eps"; output Boolean result "True, if abs(u1-u2) <= eps"; end isEqual;