相关疑难解决方法(0)

如何检查某个位的值是否等于 1?

我有一个正在运行的 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)

c# bit opencl

1
推荐指数
1
解决办法
4526
查看次数

标签 统计

bit ×1

c# ×1

opencl ×1