Is float comparison in C# deterministic?

Viewed 294

If you assign a floating point number to a variable and assign this variable to another, is it guaranteed, that the comparison of these two variables always evaluates to true?

Considering the following code.

var r = new Random();
float a = (float)r.NextDouble();
float b = a;
Console.WriteLine(a == b); // Is this guaranteed to print true?

EDIT: Lets assume the value cannot be NaN.

0 Answers
Related