简体   繁体   中英

CUDA Floating Point Compare

I was wondering if anybody has a good implementation of floating point/ double comparison for CUDA. I'd like to use something (semi) standard, instead of writing my own. I couldn't find something standard, or endorsed by CUDA. But here are some good resources on the topic:

http://developer.download.nvidia.com/assets/NVIDIA-CUDA-Floating-Point.pdf

http://www.mrupp.info/Data/2007floatingcomp.pdf

something with following header, optimized for running on CUDA // Usable AlmostEqual function bool fcmp(double a, double b)

cheers, Ashkan

There are several ways to compare floating point numbers. You can look at the absolute difference between the numbers. You can look at the relative difference between the numbers, taking the absolute difference divided by whichever number is the reference. You can look at bitwise equality of the floating point representations.

Without knowing why you're comparing two numbers it's hard to say which is best for you. There is no official CUDA-endorsed way to compare floating point numbers, other than the == operator which is defined by IEEE-754.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM