我正在编写一个用于在十进制和二进制基数系统之间进行转换的函数,这是我的原始代码:
void binary(int number)
{
vector<int> binary;
while (number == true)
{
binary.insert(binary.begin(), (number % 2) ? 1 : 0);
number /= 2;
}
for (int access = 0; access < binary.size(); access++)
cout << binary[access];
}
但是在我这样做之前它没有用:
while(number)
怎么了
while(number == true)
这两种形式有什么区别?提前致谢。