djdeejay djdeejay - 1 year ago 82
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download