djdeejay djdeejay - 11 months ago 44
Java Question

java print to file cuts last digit of number

Intentionally left blank, bye bye

Answer Source

There is nothing wrong with the println. Your code does exactly what I'd expect it to do. Consider the last line, which you claim isn't correct:


The decimal 1023 is 1111111111 in binary. Therefore when i=1023, the inner loop of your program would simply compute the sum of all numbers in list. These numbers add up to 3850, which is what gets printed.