Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static string ZwrocBinarnie2(int liczba)
- {
- if (liczba >= 0)
- {
- string output = "";
- if (liczba == 0)
- {
- return "0";
- }
- while (liczba != 0)
- {
- output = Convert.ToString(liczba & 1) + output;
- liczba >>= 1;
- }
- return output;
- }
- else
- {
- string output = "";
- liczba = liczba * (-1);
- liczba = ~liczba;
- liczba++;
- while (liczba != -1)
- {
- output = Convert.ToString(liczba & 1) + output;
- liczba >>= 1;
- }
- for (int i = output.Length; i < 32; i++)
- {
- output = "1" + output;
- }
- return output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement