CSharp examples for System:Array Compare
Compare two float arrays using a given tolerance.
/*//from ww w .j a va 2 s .c o m * Copyright: Thomas McGlynn 1997-2007. * * The CSharpFITS package is a C# port of Tom McGlynn's * nom.tam.fits Java package, initially ported by Samuel Carliles * * Copyright: 2007 Virtual Observatory - India. * * Use is subject to license terms */ using System.Collections; using System; public class Main{ /// <summary> Compare two float arrays using a given tolerance.</summary> static bool FloatArrayEquals(float[] x, float[] y, float tol) { for (int i = 0; i < x.Length; i += 1) { if (x[i] == 0) { return y[i] == 0; } if (Math.Abs((y[i] - x[i]) / x[i]) > tol) { return false; } } return true; } }