package org.joda.time.field;

import org.joda.time.DateTimeFieldType;
import org.joda.time.IllegalFieldValueException;

/* loaded from: classes5.dex */
public abstract class d {
    public static boolean a(Object obj, Object obj2) {
        if (obj == obj2) {
            return true;
        }
        if (obj == null || obj2 == null) {
            return false;
        }
        return obj.equals(obj2);
    }

    public static int b(int i10, int i11) {
        int i12 = i10 + i11;
        if ((i10 ^ i12) >= 0 || (i10 ^ i11) < 0) {
            return i12;
        }
        throw new ArithmeticException("The calculation caused an overflow: " + i10 + " + " + i11);
    }

    public static long c(long j10, long j11) {
        long j12 = j10 + j11;
        if ((j10 ^ j12) >= 0 || (j10 ^ j11) < 0) {
            return j12;
        }
        throw new ArithmeticException("The calculation caused an overflow: " + j10 + " + " + j11);
    }

    public static long d(long j10, int i10) {
        if (i10 == -1) {
            if (j10 != Long.MIN_VALUE) {
                return -j10;
            }
            throw new ArithmeticException("Multiplication overflows a long: " + j10 + " * " + i10);
        }
        if (i10 == 0) {
            return 0L;
        }
        if (i10 == 1) {
            return j10;
        }
        long j11 = i10;
        long j12 = j10 * j11;
        if (j12 / j11 == j10) {
            return j12;
        }
        throw new ArithmeticException("Multiplication overflows a long: " + j10 + " * " + i10);
    }

    public static long e(long j10, long j11) {
        if (j11 == 1) {
            return j10;
        }
        if (j10 == 1) {
            return j11;
        }
        if (j10 == 0 || j11 == 0) {
            return 0L;
        }
        long j12 = j10 * j11;
        if (j12 / j11 == j10 && ((j10 != Long.MIN_VALUE || j11 != -1) && (j11 != Long.MIN_VALUE || j10 != -1))) {
            return j12;
        }
        throw new ArithmeticException("Multiplication overflows a long: " + j10 + " * " + j11);
    }

    public static long f(long j10, long j11) {
        long j12 = j10 - j11;
        if ((j10 ^ j12) >= 0 || (j10 ^ j11) >= 0) {
            return j12;
        }
        throw new ArithmeticException("The calculation caused an overflow: " + j10 + " - " + j11);
    }

    public static int g(long j10) {
        if (-2147483648L <= j10 && j10 <= 2147483647L) {
            return (int) j10;
        }
        throw new ArithmeticException("Value cannot fit in an int: " + j10);
    }

    public static void h(org.joda.time.b bVar, int i10, int i11, int i12) {
        if (i10 < i11 || i10 > i12) {
            throw new IllegalFieldValueException(bVar.s(), Integer.valueOf(i10), Integer.valueOf(i11), Integer.valueOf(i12));
        }
    }

    public static void i(DateTimeFieldType dateTimeFieldType, int i10, int i11, int i12) {
        if (i10 < i11 || i10 > i12) {
            throw new IllegalFieldValueException(dateTimeFieldType, Integer.valueOf(i10), Integer.valueOf(i11), Integer.valueOf(i12));
        }
    }
}
