Fix range warning in ArrayHandleCast

`ArrayHandleCast` was giving warnings about casting to a type that could
not hold the range to the source even when that was not true. The
problem was it was using `std::numeric_limits::min` for the lower end of
the range. But for floating point values, `min` is not really `min`.
Rather, it is the smallest representable number. (This is probably a C++
bug we are stuck with.) You really need to use `lowest`.
This commit is contained in:
Kenneth Moreland 2022-02-01 11:42:16 -07:00
parent 2aed0b81c3
commit e16fa28d6d

@ -184,8 +184,8 @@ private:
using SrcLimits = std::numeric_limits<SrcComp>;
using DstLimits = std::numeric_limits<DstComp>;
const vtkm::Range SrcRange{ SrcLimits::min(), SrcLimits::max() };
const vtkm::Range DstRange{ DstLimits::min(), DstLimits::max() };
const vtkm::Range SrcRange{ SrcLimits::lowest(), SrcLimits::max() };
const vtkm::Range DstRange{ DstLimits::lowest(), DstLimits::max() };
const bool RangeLoss = (SrcRange.Max > DstRange.Max || SrcRange.Min < DstRange.Min);
const bool PrecLoss = SrcLimits::digits > DstLimits::digits;