How to print the bits of an integer in 16 bit format with C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        int num = 17;
        
        Console.WriteLine(Convert.ToString(num, 2).PadLeft(16, '0'));
    }
}




/*
run:

0000000000010001

*/

 



answered Jan 9, 2023 by avibootz

Related questions

1 answer 125 views
1 answer 112 views
1 answer 149 views
2 answers 142 views
1 answer 118 views
...