numeric_helpers.h 864 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. namespace NYT {
  3. ////////////////////////////////////////////////////////////////////////////////
  4. template <class T>
  5. T DivCeil(const T& numerator, const T& denominator);
  6. //! A version of division that is a bit less noisy around the situation
  7. //! when numerator is almost divisible by denominator. Round up if the remainder
  8. //! is at least half of denominator, otherwise round down.
  9. template<class T>
  10. T DivRound(const T& numerator, const T& denominator);
  11. template <class T>
  12. T RoundUp(const T& numerator, const T& denominator);
  13. template <class T>
  14. T RoundDown(const T& numerator, const T& denominator);
  15. template <class T>
  16. int GetSign(const T& value);
  17. ////////////////////////////////////////////////////////////////////////////////
  18. } // namespace NYT
  19. #define NUMERIC_HELPERS_INL_H_
  20. #include "numeric_helpers-inl.h"
  21. #undef NUMERIC_HELPERS_INL_H_