JOIN
Get Time
forums   
Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings
View: Flat (newest first)  | Threaded  | Tree
Previous Thread  |  Next Thread
Error in example? | Reply
Hi,

The description of solving the basic Nim problem with xor has an example:

"Examples:
Position (1, 2, 3) is losing because 1 xor 2 xor 3 = (1)2 xor (10)2 xor (11)2 = 0
Position (7, 4, 1) is winning because 7 xor 4 xor 1 = (111)2 xor (10)2 xor (1)2 = (10)2 = 2"

I think the binary representation of the numbers is incorrect.
It should be 7 xor 4 xor 1 = (111)2 xor (100)2 xor (1)2 = (10)2 = 2

Thanks,
Robert
Re: Error in example? (response to post by feketrob) | Reply
Integer Representation

Bit-- Binary Digit
1 byte = 8 bits
1 word = N bytes, take N to be 2 (e.g., 16 bit machine)
Integer takes up 2 bytes; can be signed or unsigned.
Unsigned Integers

Can represent whole numbers from 0 to 65,535
(0 to 216 - 1).
In binary, this is from
02 to 11111111111111112
Internally, binary representation of decimal value as 16 bits.
Signed Integers

Need to reserve one bit for the sign.
Three ways:
Sign-Magnitude
1's Complement
2's Complement
Sign-Magnitude

Uses most significant bit of the word to represent the sign.
0 - Positive
1 - Negative.
Rest of the number is encoded in magnitude part
37 = 00000000 00100101
-37 = 10000000 00100101
6712 = 00011010 00111000
-6712 = 10011010 00111000
Can represent numbers from -32,767 to 32,767.
-215+1 .. 215-1
But, two representations for zero:
0 = 00000000 00000000
-0 = 10000000 00000000
Arithmetic can be cumbersome. Write my Paper for me Cheap
RSS