https://msdn.microsoft.com/en-us/library/k9hz8w9t (v=vs.110). aspx
Compares-single-precision floating point numbers for equality and, if they is equal, replaces the first value.
/// <summary> ///Compare the values of Location1 and Comparand, and if their values are equal, replace the value of Location1 with value/// </summary> /// <param name= "Location1" >the destination, whose value is compared with comparand and possibly replaced.</param> /// <param name= "value" >The value is replaces the destination value if the comparison results in equality.</param> /// <param name= "Comparand" >The value is compared to the value at Location1.</param> /// <returns>The original value in Location1.</returns> Public Static floatCompareExchange (ref floatLocation1,floatValuefloatComparand)
Remarks
If comparand and the value in location1 was equal, then value was stored in location1 .
Otherwise, no operation is performed.
The Compare and exchange operations is performed as an atomic operation.
The return value of CompareExchange is the original value in location1, whether or not the exchange takes place .//Regardless of whether exchange occurs, the return value is the original value of Location1
public static float CompareExchange (ref float location1,float value,float comparand)