I have a method returning long and there are cases where a valid result can not be computed. Double has the NaN constant, which is not expressable in long.
I can think of two solutions:
- throw an exception
- change the method’s signature to return
double, check for NaN and convert tolongif everything is fine.
Is either preferrable / more “Javanic”? Are there other ways / Did I miss something obvious?
You can make the return-type
Long(the boxed version oflong) and returnnull.