Where Java system properties come from

The reference implementation of Java, OpenJDK, has been open source since a long time now, which means we can look under the covers and see the minute implementation details of anything we find interesting or the API doesn’t fully specify. For example, let’s have a look at how the system properties like file.encoding, os.name and java.io.tmpdir get their values.

Continue reading “Where Java system properties come from”

When 0.3 is not 3/10

If you’ve taken a course in numerical computing you’ll be familiar with the various sources of numerical error. First you have representation error that arises when you have to represent a number with a finite number of digits. A common example: the decimal expansion for 1/3 = 0.3333… has a never-ending string of 3’s and at some point you just have to cut it. The same happens with 1/10 in binary. When you start adding (or subtracting) you may fall victim to loss of significance: when the two numbers have drastically different magnitude you lose least significant digits in the smaller one. You can also have cancellation: when two numbers have almost equal magnitude but opposite signs, you lose the most significant digits and produce a large relative error. You may also suffer from overflow and underflow when magnitude of intermediate or final results gets out of the representable range.

Continue reading “When 0.3 is not 3/10”