aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/rounding.h
blob: 11ab90b8df2814effb73fb587c5e39cccdcefe69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* Integer Rounding Functions
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/

#ifndef BOTAN_ROUNDING_H__
#define BOTAN_ROUNDING_H__

#include <botan/types.h>

namespace Botan {

/*
* Round up n to multiple of align_to
*/
inline u32bit round_up(u32bit n, u32bit align_to)
   {
   if(n % align_to || n == 0)
      n += align_to - (n % align_to);
   return n;
   }

/*
* Round down n to multiple of align_to
*/
inline u32bit round_down(u32bit n, u32bit align_to)
   {
   return (n - (n % align_to));
   }

}

#endif