我有一个正在运行的 OpenCL 内核。如何检查变量中选定位置的一位是否等于 1?
例如,我发现在 C# 中我们可以使用如下uint
代码转换为包含位的字符串:
// Here we will store our bit
string bit;
// Unsigned integer that will be converted
uint hex = 0xfffffffe;
// Perform conversion and store our string containing bits
string str = uint2bits(hex);
// Print all bits "11111111111111111111111111111110"
Console.WriteLine(str);
// Now get latest bit from string
bit = str.Substring(31, 1);
// And print it to console
Console.WriteLine(bit);
// This function converts uint to string containing bits
public static string uint2bits(uint …
Run Code Online (Sandbox Code Playgroud)