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
Tag: casting
How do I convert from int to Long in Java?
I keep finding both on here and Google people having troubles going from long to int and not the other way around. Yet I’m sure I’m not the only one that has run into this scenario before going from int to Long. The only other answers I’ve found were “Just set it as Long in the first place” which really