public static double floor(double x) {
		long y;

		if (x != x) { // NaN
			return x;
		}

		if (x >= TWO_POWER_52 || x <= -TWO_POWER_52) {
			return x;
		}

		y = (long) x;
		if (x < 0 && y != x) {
			y--;
		}

		if (y == 0) {
			return x * y;
		}

		return y;
	}