Skip to content

Commit

Permalink
Update CalculateBin for special bool case
Browse files Browse the repository at this point in the history
  • Loading branch information
nyoungbq authored Sep 25, 2024
1 parent 34cf3a7 commit a31a27a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/simplnx/Utilities/HistogramUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@ void FillBinRanges(Container& outputContainer, const std::pair<Type, Type>& rang
}

template <typename Type>
Type CalculateBin(Type value, Type min, float32 increment)
auto CalculateBin(Type value, Type min, float32 increment)
{
return static_cast<Type>(std::floor(static_cast<float32>(value - min) / increment));
if constexpr(std::is_same_v<Type, bool>)
{
return static_cast<uint8>(std::floor(static_cast<float32>(static_cast<uint8>(value) - static_cast<uint8>(min)) / increment));
}
else
{
return static_cast<Type>(std::floor(static_cast<float32>(value - min) / increment));
}
}

/**
Expand Down

0 comments on commit a31a27a

Please sign in to comment.