For this code block: the value of d is 0.0. It can be forced to work by casting: But is there another way to get the correct double result? I don’t like casting primitives, who knows what may happen. Answer That avoids a cast. But you’ll find that the cast conversions are well-defined. You don’t have to guess, just check