Gray code: Difference between revisions

175 bytes removed ,  11 months ago
m
Test results were overflowing the length of a line.
(An existing post had a warning message on a yellow background stating that the code had not been fully tested. This post adds the missing tests while altering the existing post as little as possible.)
m (Test results were overflowing the length of a line.)
Line 3,224:
System.out.println();
final BigInteger base = BigInteger.TEN.pow(3025).add( new BigInteger("12345678901234567890") );
for ( int i = 0; i < 5; i++ ) {
BigInteger test = base.add(BigInteger.valueOf(i));
Line 3,275:
31 11111 10000 10000 31
 
test decimal = 100000000001234567890123456789010000012345678901234567890
gray code decimal = 85688036248897844223633002079514995268463904422838177723
gray code binary = 110001100111010111110010000111011100111111111011111110101111100100001000111110111011
gray code binary = 1010110100001011101011010010101110001000100100101101010111001100110010111110100100001000111110111011
decoded decimal = 100000000001234567890123456789010000012345678901234567890
decoded2 decimal = 100000000001234567890123456789010000012345678901234567890
 
test decimal = 100000000001234567890123456789110000012345678901234567891
gray code decimal = 85688036248897844223633002079414995268463904422838177722
gray code binary = 110001100111010111110010000111011100111111111011111110101111100100001000111110111010
gray code binary = 1010110100001011101011010010101110001000100100101101010111001100110010111110100100001000111110111010
decoded decimal = 100000000001234567890123456789110000012345678901234567891
decoded2 decimal = 100000000001234567890123456789110000012345678901234567891
 
test decimal = 100000000001234567890123456789210000012345678901234567892
gray code decimal = 85688036248897844223633002079814995268463904422838177726
gray code binary = 110001100111010111110010000111011100111111111011111110101111100100001000111110111110
gray code binary = 1010110100001011101011010010101110001000100100101101010111001100110010111110100100001000111110111110
decoded decimal = 100000000001234567890123456789210000012345678901234567892
decoded2 decimal = 100000000001234567890123456789210000012345678901234567892
 
test decimal = 100000000001234567890123456789310000012345678901234567893
gray code decimal = 85688036248897844223633002079914995268463904422838177727
gray code binary = 110001100111010111110010000111011100111111111011111110101111100100001000111110111111
gray code binary = 1010110100001011101011010010101110001000100100101101010111001100110010111110100100001000111110111111
decoded decimal = 100000000001234567890123456789310000012345678901234567893
decoded2 decimal = 100000000001234567890123456789310000012345678901234567893
 
test decimal = 100000000001234567890123456789410000012345678901234567894
gray code decimal = 85688036248897844223633002079714995268463904422838177725
gray code binary = 110001100111010111110010000111011100111111111011111110101111100100001000111110111101
gray code binary = 1010110100001011101011010010101110001000100100101101010111001100110010111110100100001000111110111101
decoded decimal = 100000000001234567890123456789410000012345678901234567894
decoded2 decimal = 100000000001234567890123456789410000012345678901234567894
</pre>
 
871

edits