Index: base/bits.h |
diff --git a/base/bits.h b/base/bits.h |
index b2209e8ed7934a6dfc918c3d7d12b9c455f594e1..9383f8832408c7da40fa47ec49a4325c778f89ac 100644 |
--- a/base/bits.h |
+++ b/base/bits.h |
@@ -41,6 +41,16 @@ inline int Log2Ceiling(uint32 n) { |
} |
} |
+// Returns the largest i such as i <= n and i == k * mul for some integer k |
+inline uint32 RoundDown(uint32 n, uint32 mul) { |
+ return (n / mul) * mul; |
+} |
+ |
+// Returns the smallest i such as i >= n and i == k * mul for some integer k |
+inline uint32 RoundUp(uint32 n, uint32 mul) { |
+ return (n + (mul - 1)) / mul * mul; |
jar (doing other things)
2012/11/20 22:54:35
Does this do what you want when:
n + mul - 1 > UIN
sheu
2012/11/20 23:13:50
It doesn't but I don't really have other suggestio
|
+} |
+ |
} // namespace bits |
} // namespace base |