[java] How to convert a double to long without casting?