|
|
|
|
|
by xxs
3450 days ago
|
|
I think it's =much= easier to read compared to the one in the article.
Although the usual approach is bit shifting the input and checking only the lowest/highest bit.
Here is an example in Java: static void bin(int n) {
for (int i=0; i<32; i++, n<<=1) System.out.print(n<0 ? '1': '0');
}
|
|