We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 63fe052 commit 072b6f2Copy full SHA for 072b6f2
libc/src/__support/fixed_point/fx_bits.h
@@ -163,6 +163,13 @@ template <typename T> LIBC_INLINE constexpr T round(T x, int n) {
163
return bit_and((x + round_bit), rounding_mask);
164
}
165
166
+// u?int_fx_t --> Fixed point
167
+template <typename T, typename XType> LIBC_INLINE constexpr T fxbits(XType x) {
168
+ // Example: rbits(0x2000) where fract has 15 fractional bits,
169
+ // 0x2000 --> 0010 0000 0000 0000 --> 0.010 0000 0000 0000 = 0.25
170
+
171
+ return cpp::bit_cast<T, XType>(x);
172
+}
173
} // namespace fixed_point
174
} // namespace LIBC_NAMESPACE_DECL
175
0 commit comments