Should I use floating point's NaN, or floating point + bool for a data set that contains invalid values?

后端 未结 3 774
挽巷
挽巷 2020-12-31 01:14

I have a large amount of data to process with math intensive operations on each data set. Much of it is analogous to image processing. However, since this data is read direc

3条回答
  •  再見小時候
    2020-12-31 01:53

    Since the floating-point numbers come from a device, they probably have a limited range. You can use some other special number, rather than NaN, to indicate absense of data, e.g. 1e37. This solution is portable. I do not know whether or not is more convinient for you than using a bool flag.

提交回复
热议问题