Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Please help - convert to negative base

3 views
Skip to first unread message

remlaps

unread,
Jul 13, 2006, 5:20:53 PM7/13/06
to
Can anyone please provide me with a link to an online description
of an algorithm for converting a numeric representation from a positive
radix to a negative one? I don't have convenient access to a copy of
"The Art of Computer Programming", so suggestions other than
"try Knuth" would be greatly appreciated.

Thanks in advance,
Steve

PS- Not homework. Just for fun. :-)

Proginoskes

unread,
Jul 13, 2006, 7:27:37 PM7/13/06
to

remlaps wrote:
> Can anyone please provide me with a link to an online description
> of an algorithm for converting a numeric representation from a positive
> radix to a negative one? I don't have convenient access to a copy of
> "The Art of Computer Programming", so suggestions other than
> "try Knuth" would be greatly appreciated.

Try MathWorld.

http://mathworld.wolfram.com/Negabinary.html
http://mathworld.wolfram.com/Negadecimal.html

Or Wikipedia (which works an example in negabinary).

http://en.wikipedia.org/wiki/Negabinary

Or HAKMEM (lots of useful math stuff, at
http://www.inwap.com/pdp10/hbaker/hakmem/hakmem.html ):

http://www.inwap.com/pdp10/hbaker/hakmem/flows.html#item128

--- Christopher Heckman

remlaps

unread,
Jul 13, 2006, 8:28:14 PM7/13/06
to
>
> http://en.wikipedia.org/wiki/Negabinary
>
> --- Christopher Heckman

Perfect. Thank you!

Steve

jasen

unread,
Jul 14, 2006, 8:03:58 AM7/14/06
to
On 2006-07-13, remlaps <rem...@gmail.com> wrote:
> Can anyone please provide me with a link to an online description
> of an algorithm for converting a numeric representation from a positive
> radix to a negative one? I don't have convenient access to a copy of
> "The Art of Computer Programming", so suggestions other than
> "try Knuth" would be greatly appreciated.

use the normal base conversion algortithm (repeated division recording the
remainders)


to cobvert 74 to base -3


74/-3 = -24 r 2

-24/-3 = 8 r 0

8/-3 = -2 r 2

-2/-3 = 1 r 1

1/-3 = 0 r 1

answer is 11202


1 * 81 + 1 * -27 + 2 * 9 + 0 * -3 + 2 * 1



Bye.
Jasen

0 new messages