Coursera algorithm class, there is a material (FAQ"s eighth question) that mentions that floating point numbers can be directly compared in this course project. The specific situation is as follows:
enter integers a
and b
in the range of [- 32 767, 32767]
. Compare floating point numbers a1/b1
with a2/b2
directly to get the correct answer. The reason is that IEEE-754 specifies that floating-point budget results are represented by proximity values.
but I"m still not sure why the results can be compared directly by using proximity values. Although it is not a good habit to compare floating point numbers directly, under what circumstances can floating point numbers be compared directly?