New in Java 8: Catching Integer Overflows

I’ve recently discovered a nice new feature in Java 8: methods to properly handle integer overflows. Consider the following example: When you compile and run it, this is the result: Quite obviously, this can’t be mathematically right. The problem occurs because an int has a limited size of 4 byte. When this size is tooContinue reading “New in Java 8: Catching Integer Overflows”

Good documentation can be funny

java.lang.System.nanoTime() is used to measure time spans as precisely as possible (if you actually get nanosecond precision depends on the platform). I just found a funny warning in the documentation: Differences in successive calls that span greater than approximately 292 years (263 nanoseconds) will not accurately compute elapsed time due to numerical overflow. I didn’tContinue reading “Good documentation can be funny”

Design a site like this with WordPress.com
Get started