package org.joda.time.format;

import com.fasterxml.jackson.core.JsonFactory;
import java.io.IOException;

/* loaded from: classes5.dex */
public abstract class h {

    /* renamed from: a, reason: collision with root package name */
    private static final double f32113a = Math.log(10.0d);

    public static void a(Appendable appendable, int i10, int i11) {
        if (i10 < 0) {
            appendable.append('-');
            if (i10 == Integer.MIN_VALUE) {
                while (i11 > 10) {
                    appendable.append('0');
                    i11--;
                }
                appendable.append("2147483648");
                return;
            }
            i10 = -i10;
        }
        if (i10 < 10) {
            while (i11 > 1) {
                appendable.append('0');
                i11--;
            }
            appendable.append((char) (i10 + 48));
            return;
        }
        if (i10 >= 100) {
            int log = i10 < 1000 ? 3 : i10 < 10000 ? 4 : ((int) (Math.log(i10) / f32113a)) + 1;
            while (i11 > log) {
                appendable.append('0');
                i11--;
            }
            appendable.append(Integer.toString(i10));
            return;
        }
        while (i11 > 2) {
            appendable.append('0');
            i11--;
        }
        int i12 = ((i10 + 1) * 13421772) >> 27;
        appendable.append((char) (i12 + 48));
        appendable.append((char) (((i10 - (i12 << 3)) - (i12 << 1)) + 48));
    }

    public static void b(StringBuffer stringBuffer, int i10, int i11) {
        try {
            a(stringBuffer, i10, i11);
        } catch (IOException unused) {
        }
    }

    public static void c(Appendable appendable, int i10) {
        if (i10 < 0) {
            appendable.append('-');
            if (i10 == Integer.MIN_VALUE) {
                appendable.append("2147483648");
                return;
            }
            i10 = -i10;
        }
        if (i10 < 10) {
            appendable.append((char) (i10 + 48));
        } else {
            if (i10 >= 100) {
                appendable.append(Integer.toString(i10));
                return;
            }
            int i11 = ((i10 + 1) * 13421772) >> 27;
            appendable.append((char) (i11 + 48));
            appendable.append((char) (((i10 - (i11 << 3)) - (i11 << 1)) + 48));
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static String d(String str, int i10) {
        int i11 = i10 + 32;
        String concat = str.length() <= i11 + 3 ? str : str.substring(0, i11).concat("...");
        if (i10 <= 0) {
            return "Invalid format: \"" + concat + JsonFactory.DEFAULT_QUOTE_CHAR;
        }
        if (i10 >= str.length()) {
            return "Invalid format: \"" + concat + "\" is too short";
        }
        return "Invalid format: \"" + concat + "\" is malformed at \"" + concat.substring(i10) + JsonFactory.DEFAULT_QUOTE_CHAR;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static int e(CharSequence charSequence, int i10) {
        int charAt = charSequence.charAt(i10) - '0';
        return (((charAt << 3) + (charAt << 1)) + charSequence.charAt(i10 + 1)) - 48;
    }
}
