tlx
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
round_up.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/math/round_up.hpp
3
*
4
* Part of tlx - http://panthema.net/tlx
5
*
6
* Copyright (C) 2019 Timo Bingmann <tb@panthema.net>
7
*
8
* All rights reserved. Published under the Boost Software License, Version 1.0
9
******************************************************************************/
10
11
#ifndef TLX_MATH_ROUND_UP_HEADER
12
#define TLX_MATH_ROUND_UP_HEADER
13
14
namespace
tlx
{
15
16
//! \addtogroup tlx_math
17
//! \{
18
19
/******************************************************************************/
20
// round_up() - round n up to the next multiple of k
21
22
//! round n up to the next multiple of k, for n and k positive!
23
template
<
typename
IntegralN,
typename
IntegralK>
24
static
inline
constexpr
25
auto
round_up
(
const
IntegralN& n,
const
IntegralK& k)->decltype(n + k) {
26
return
((n + k - 1) / k) * k;
27
}
28
29
//! \}
30
31
}
// namespace tlx
32
33
#endif // !TLX_MATH_ROUND_UP_HEADER
34
35
/******************************************************************************/
tlx
Definition:
exclusive_scan.hpp:17
tlx::round_up
static constexpr auto round_up(const IntegralN &n, const IntegralK &k) -> decltype(n+k)
round n up to the next multiple of k, for n and k positive!
Definition:
round_up.hpp:25
tlx
math
round_up.hpp
Generated on Sat Oct 2 2021 20:29:00 for tlx by
1.8.11