Bits positioning and numbering would be interesting to represent here.. for
example...

2 = 110 == (1*(-2)^2  + 1*(-2)^1 + 0*(-2)^0)  == (4 + (-2) + 0 )
3 = 111 == (1 *(-2)^2 + 1*(-2)^1 + 1*(-2)^0)  == (4 + (-2) + 1)
4 = 100 == (1 *(-2)^2 + 0*(-2)^1 + 0*(-2)^0)  == (4 + 0 + 0)
5 = 101 == (1 *(-2)^2 + 0*(-2)^1 + 1*(-2)^0)  == (4 + 0 + 1)
6 = 11010 == (1 *(-2)^4+ 1 *(-2)^3 + 0 *(-2)^2 + 1*(-2)^1 + 0*(-2)^0) == (16
+ (-8) + 0 + (-2) + 0)

and so on. There would be always odd no. of bits.
Also no. of bits would be not as per the base +2 notation.

It ends up finding the combination of positive even powers of 2 and negative
odd powers of 2 that forms the no.




On Mon, Aug 30, 2010 at 2:37 PM, Maria <[email protected]> wrote:

> Write some code to convert a positive integer into base minus 2. That
> is, whereas base 2 has a 1's place, a 2's place, a 4's place, etc.,
> base minus 2 has a 1's place, a minus 2's place, a 4's place, a minus
> 8's place, ... (-2)^n.
>
> --
> 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]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
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.

Reply via email to