Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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');		
  }


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: