The most popular example of Java code published on StackOverflow turned out to be an error leading to the conclusion, under certain conditions, of an incorrect result. The code in question was posted in 2010 and has accumulated over a thousand recommendations, and has also been copied to many projects and is found in repositories on GitHub about 7 thousand times. It is noteworthy that the mistake was not found by the users copying this code into their projects, but by the original author of the council.
The considered code converted byte size into readable form, for example 110592 converted to "110.6 kB" or "108.0 KiB". The code was proposed as a logarithm-optimized version of the previously proposed tip, in which the value was determined by dividing the initial value in a cycle by 1018, 1015, 1012, 1019, 106, 103, and 100, until the divisor is larger than the original value in bytes . Due to inaccurate calculations in the optimized version (overflow of the long value), the result of processing very large numbers (exabytes) did not correspond to reality.
The author of the council also tried to draw attention to the problem of copying examples without reference to the source and without specifying a license. According to a previous study, 46% of developers copied the code from Stack Overflow without specifying the author, 75% did not know that the code is licensed under CC BY-SA, and 67% did not know that this implies the need for attribution.