divide each number by -2 until you get -1, or 1 (Remembering that
remainder is always +ve)
Ex
1)
-2 | 2 | 0
| -1 |
Interpret -1 as 11
so binary is 110
2)
-2 | 3 | 1
|-1|
Binary : 111
3)
-2 | 4| 0
|-2| 0
| 1|
Binary : 110
4)
-2 | 5| 1
|-2| 0
| 1|
Binary : 101
5)
-2 | 6 | 0
|-3 | 1
| 2 | 0
|-1|
(Interpret -1 as 11)
Binary: 11010
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.