Unless of course you wanted to write the number out in base 5 :)
Printable View
Unless of course you wanted to write the number out in base 5 :)
I must have missed something. Was that a requirement, or do you just work with base 5 a lot? ;)
Yeah its for when I work with pennies, nickles, and quarters. One of my professors just loves base conversions. I had to do it in pascal and in assembly. The "Read in a base 9 number and output it as a base 7 number." Fun stuff
Oh, I had to do that in Haskell. Any base between 2 and 36, and then base -2 for good measure. (Now THAT's a weird number system.)
How do you have a negative base? The base is suppose to represent the number of different symbols that are used.
In pascal I once did a base (26*2 + 10) 62 system :)
No, in the definition my professor used, a number system is done like so:
number = SUM[i = 0 to digit-count](base^i * digit-value)
So base can be any integer except -1, 0 and 1, as long as you have enough digit signs.
In base -2, with four digits you get these numbers:
0000 = 0
0001 = 1
0010 = -2
0011 = -1
0100 = 4
0101 = 5
0110 = 2
0111 = 3
1000 = -8
1001 = -7
1010 = -10
1011 = -9
1100 = -4
1101 = -3
1110 = -6
1111 = -5
etc. etc.
I think your professor had to dig deep in his arse to find that defination :)
Well...
The "negabinary" system is listed at Wikipedia as a "positional-like system with non-standard base". The German Wikipedia states in a paragraph that as a generalization of numbering systems, the base need not be a natural number as longas the absolute value of the base is greater than 1.
http://en.wikipedia.org/wiki/Negabinary
I even had to implement the addition.
Hmm interesting. Though something doesn't seem rightbut it still takes 1 extra bit.Quote:
unusual property that negative and positive numbers can be represented without a sign bit
This has gone way too off-topic.
Sportsmaniac, if you're still stuck, start a new thread with your latest code and question(s).