Friday 29 March 2019

c++ - double or float comparison

I've seen posts like:



What is the most effective way for float and double comparison?



Compare two floats



And many other related posts.



I saw in d3js library, it uses the following comparison:




  return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;


Is it OK to use this in C/C++ to do the comparison of double and float?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...