Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean isInteger(double d) {
- if (d != d) {
- return false;
- }
- long bits = Double.doubleToRawLongBits(d);
- long exponent = ((bits >> 52) & 0x7FF)-1023;
- long fraction = bits & 0xFFFFFFFFFFFFFL;
- long l = 52-exponent;
- return (fraction & ~(fraction >> l << l)) == 0;
- }
Add Comment
Please, Sign In to add comment