public String fractionToDecimal(int numerator, int denominator) {
        if (numerator == 0)
            return "0";
        String res = "";
        if (numerator < 0 ^ denominator < 0)
            res += "-";
        long n = Math.abs(numerator);
        long d = Math.abs(denominator);
        res += String.valueOf(n / d);
        if (n % d== 0)
            return res;
        res += ".";
        HashMap<Long, Integer> hashMap = new HashMap<Long, Integer>();
        for (long r =n % d; r > 0; r %= d) {
            if (hashMap.containsKey(r)) {
                res = res.substring(0, hashMap.get(r)) + "(" + res.substring(hashMap.get(r), res.length());
                res += ")";
                break;
            }
            hashMap.put(r, res.length());
            r *= 10;
            res += String.valueOf(r / denominator);
        }
        return res;
    }