From Jason Turner

[bit.pow.two]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpvu4_wnaw/{from.md → to.md} +50 -0
tmp/tmpvu4_wnaw/{from.md → to.md} RENAMED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Integral powers of 2 <a id="bit.pow.two">[[bit.pow.two]]</a>
2
+
3
+ ``` cpp
4
+ template<class T>
5
+ constexpr bool has_single_bit(T x) noexcept;
6
+ ```
7
+
8
+ *Constraints:* `T` is an unsigned integer type [[basic.fundamental]].
9
+
10
+ *Returns:* `true` if `x` is an integral power of two; `false` otherwise.
11
+
12
+ ``` cpp
13
+ template<class T>
14
+ constexpr T bit_ceil(T x);
15
+ ```
16
+
17
+ Let N be the smallest power of 2 greater than or equal to `x`.
18
+
19
+ *Constraints:* `T` is an unsigned integer type [[basic.fundamental]].
20
+
21
+ *Preconditions:* N is representable as a value of type `T`.
22
+
23
+ *Returns:* N.
24
+
25
+ *Throws:* Nothing.
26
+
27
+ *Remarks:* A function call expression that violates the precondition in
28
+ the *Preconditions:* element is not a core constant
29
+ expression [[expr.const]].
30
+
31
+ ``` cpp
32
+ template<class T>
33
+ constexpr T bit_floor(T x) noexcept;
34
+ ```
35
+
36
+ *Constraints:* `T` is an unsigned integer type [[basic.fundamental]].
37
+
38
+ *Returns:* If `x == 0`, `0`; otherwise the maximal value `y` such that
39
+ `has_single_bit(y)` is `true` and `y <= x`.
40
+
41
+ ``` cpp
42
+ template<class T>
43
+ constexpr T bit_width(T x) noexcept;
44
+ ```
45
+
46
+ *Constraints:* `T` is an unsigned integer type [[basic.fundamental]].
47
+
48
+ *Returns:* If `x == 0`, `0`; otherwise one plus the base-2 logarithm of
49
+ `x`, with any fractional part discarded.
50
+