Skip to content

Monthly Archives: December 2007

Bubble, bubble, toil and Double

Inspired by Weiqi Gao's Friday Java Quiz this week, I came up with a few more curiosities of Java double. What do each of the calls to larger() print? Hint: this puzzle has nothing to do with type conversion loss of precision, it is only about the specified behavior of doubles.

public class Foo [...]

String Theory

No, not that string theory. This string theory is testable. In fact, the moral of this story is this: don't make any assumptions about Java. The compiler or the VM. They do crazy stuff, like make your code run better. If you think you have an inefficiency in your [...]