Java long to binary

前端 未结 1 1475
一向
一向 2020-12-17 10:06

something I thought was simple ends up not so much.

I need to convert a long number to binary.

For example:

String b =  Integer.toBinaryStrin         


        
相关标签:
1条回答
  • 2020-12-17 10:30

    Add an L to indicate its a long<1> and use the Long class<2>:

    Long.toBinaryString(2199023255552L);
    

    <1> Constants in java are considered ints unless you specify otherwise.

    <2> Integer.toBinaryString() receives an int as parameter, not long.

    0 讨论(0)
提交回复
热议问题