Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class DecimalToBinary
- {
- static void Main(string[] args)
- {
- long userNum = long.Parse(Console.ReadLine());
- bool checkFirstBit = false;
- string result = "";
- for (int bit = 63; bit >= 0; bit--)
- {
- if (!checkFirstBit && (((userNum >> bit) & 1) != 1))
- {
- continue;
- }
- else
- {
- checkFirstBit = true;
- result += ((userNum >> bit) & 1).ToString();
- }
- }
- Console.WriteLine(result.Length == 0 ? "0" : result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement