JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums News, Programs & Events Discussions Algorithm Games (Article) Error in example?
 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 = 0Position (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 = 2Thanks,Robert
 Re: Error in example? (response to post by feketrob) | Reply Integer RepresentationBit-- Binary Digit1 byte = 8 bits1 word = N bytes, take N to be 2 (e.g., 16 bit machine)Integer takes up 2 bytes; can be signed or unsigned.Unsigned IntegersCan represent whole numbers from 0 to 65,535(0 to 216 - 1).In binary, this is from02 to 11111111111111112Internally, binary representation of decimal value as 16 bits.Signed IntegersNeed to reserve one bit for the sign.Three ways:Sign-Magnitude1's Complement2's ComplementSign-MagnitudeUses most significant bit of the word to represent the sign.0 - Positive1 - 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-1But, two representations for zero: 0 = 00000000 00000000-0 = 10000000 00000000 Arithmetic can be cumbersome. Write my Paper for me Cheap
 Forums News, Programs & Events Discussions Algorithm Games (Article) Error in example? Previous Thread  |  Next Thread