wxMaxima
Loading...
Searching...
No Matches
round.h
1/* Copyright 2013 Google Inc. All Rights Reserved.
2
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5*/
6
7/* Helper for rounding */
8
9#ifndef WOFF2_ROUND_H_
10#define WOFF2_ROUND_H_
11
12#include <limits>
13
14namespace woff2 {
15
16// Round a value up to the nearest multiple of 4. Don't round the value in the
17// case that rounding up overflows.
18template<typename T> T Round4(T value) {
19 if (std::numeric_limits<T>::max() - value < 3) {
20 return value;
21 }
22 return (value + 3) & ~3;
23}
24
25} // namespace woff2
26
27#endif // WOFF2_ROUND_H_