【发布时间】:2023-04-02 03:22:02
【问题描述】:
我只能得到小于五的十进制的正确输出。五个的输出是 110,而应该是 101。六个的输出是 101,十个的输出是 1100。
//while loop divides each digit
while (decimal > 0)
{
//divides and digit becomes the remainder
int digit = decimal % 2;
//makes the digit into a string builder so it can be reversed
binaryresult.append(digit);
decimal = decimal / 2;
display.setText(binaryresult.reverse());
}
【问题讨论】:
-
这篇文章可能对你有所帮助stackoverflow.com/questions/5203974/…