Rabbit-R1/original r1/java/sources/kotlin/time/LongSaturatedMathKt.java
2024-05-21 17:08:36 -04:00

84 lines
5.9 KiB
Java

package kotlin.time;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import kotlin.time.Duration;
/* compiled from: longSaturatedMath.kt */
@Metadata(d1 = {"\u0000 \n\u0000\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u000f\n\u0002\u0010\u000b\n\u0000\u001a'\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u00012\u0006\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0001H\u0002¢\u0006\u0004\b\u0006\u0010\u0007\u001a\u0015\u0010\b\u001a\u00020\u00042\u0006\u0010\u0002\u001a\u00020\u0001H\u0002¢\u0006\u0002\u0010\t\u001a'\u0010\n\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u00012\u0006\u0010\u000b\u001a\u00020\f2\u0006\u0010\u0003\u001a\u00020\u0004H\u0000¢\u0006\u0004\b\r\u0010\u000e\u001a'\u0010\u000f\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u00012\u0006\u0010\u000b\u001a\u00020\f2\u0006\u0010\u0003\u001a\u00020\u0004H\u0002¢\u0006\u0004\b\u0010\u0010\u000e\u001a%\u0010\u0011\u001a\u00020\u00042\u0006\u0010\u0012\u001a\u00020\u00012\u0006\u0010\u0013\u001a\u00020\u00012\u0006\u0010\u000b\u001a\u00020\fH\u0000¢\u0006\u0002\u0010\u0014\u001a%\u0010\u0015\u001a\u00020\u00042\u0006\u0010\u0016\u001a\u00020\u00012\u0006\u0010\u0017\u001a\u00020\u00012\u0006\u0010\u000b\u001a\u00020\fH\u0002¢\u0006\u0002\u0010\u0014\u001a%\u0010\u0018\u001a\u00020\u00042\u0006\u0010\u0019\u001a\u00020\u00012\u0006\u0010\u001a\u001a\u00020\u00012\u0006\u0010\u000b\u001a\u00020\fH\u0000¢\u0006\u0002\u0010\u0014\u001a\r\u0010\u001b\u001a\u00020\u001c*\u00020\u0001H\u0080\\u0006\u001d"}, d2 = {"checkInfiniteSumDefined", "", "value", "duration", "Lkotlin/time/Duration;", "durationInUnit", "checkInfiniteSumDefined-PjuGub4", "(JJJ)J", "infinityOfSign", "(J)J", "saturatingAdd", "unit", "Lkotlin/time/DurationUnit;", "saturatingAdd-NuflL3o", "(JLkotlin/time/DurationUnit;J)J", "saturatingAddInHalves", "saturatingAddInHalves-NuflL3o", "saturatingDiff", "valueNs", "origin", "(JJLkotlin/time/DurationUnit;)J", "saturatingFiniteDiff", "value1", "value2", "saturatingOriginsDiff", "origin1", "origin2", "isSaturated", "", "kotlin-stdlib"}, k = 2, mv = {1, 9, 0}, xi = 48)
/* loaded from: classes3.dex */
public final class LongSaturatedMathKt {
public static final boolean isSaturated(long j) {
return ((j - 1) | 1) == Long.MAX_VALUE;
}
/* renamed from: saturatingAdd-NuflL3o, reason: not valid java name */
public static final long m7153saturatingAddNuflL3o(long j, DurationUnit unit, long j2) {
Intrinsics.checkNotNullParameter(unit, "unit");
long m7070toLongimpl = Duration.m7070toLongimpl(j2, unit);
if (((j - 1) | 1) == Long.MAX_VALUE) {
return m7152checkInfiniteSumDefinedPjuGub4(j, j2, m7070toLongimpl);
}
if ((1 | (m7070toLongimpl - 1)) == Long.MAX_VALUE) {
return m7154saturatingAddInHalvesNuflL3o(j, unit, j2);
}
long j3 = j + m7070toLongimpl;
return ((j ^ j3) & (m7070toLongimpl ^ j3)) < 0 ? j < 0 ? Long.MIN_VALUE : Long.MAX_VALUE : j3;
}
/* renamed from: checkInfiniteSumDefined-PjuGub4, reason: not valid java name */
private static final long m7152checkInfiniteSumDefinedPjuGub4(long j, long j2, long j3) {
if (!Duration.m7056isInfiniteimpl(j2) || (j ^ j3) >= 0) {
return j;
}
throw new IllegalArgumentException("Summing infinities of different signs");
}
/* renamed from: saturatingAddInHalves-NuflL3o, reason: not valid java name */
private static final long m7154saturatingAddInHalvesNuflL3o(long j, DurationUnit durationUnit, long j2) {
long m7027divUwyO8pc = Duration.m7027divUwyO8pc(j2, 2);
long m7070toLongimpl = Duration.m7070toLongimpl(m7027divUwyO8pc, durationUnit);
return (1 | (m7070toLongimpl - 1)) == Long.MAX_VALUE ? m7070toLongimpl : m7153saturatingAddNuflL3o(m7153saturatingAddNuflL3o(j, durationUnit, m7027divUwyO8pc), durationUnit, Duration.m7059minusLRDsOJo(j2, m7027divUwyO8pc));
}
private static final long infinityOfSign(long j) {
return j < 0 ? Duration.INSTANCE.m7126getNEG_INFINITEUwyO8pc$kotlin_stdlib() : Duration.INSTANCE.m7125getINFINITEUwyO8pc();
}
public static final long saturatingDiff(long j, long j2, DurationUnit unit) {
Intrinsics.checkNotNullParameter(unit, "unit");
if ((1 | (j2 - 1)) == Long.MAX_VALUE) {
return Duration.m7077unaryMinusUwyO8pc(infinityOfSign(j2));
}
return saturatingFiniteDiff(j, j2, unit);
}
public static final long saturatingOriginsDiff(long j, long j2, DurationUnit unit) {
Intrinsics.checkNotNullParameter(unit, "unit");
if (((j2 - 1) | 1) == Long.MAX_VALUE) {
if (j == j2) {
return Duration.INSTANCE.m7127getZEROUwyO8pc();
}
return Duration.m7077unaryMinusUwyO8pc(infinityOfSign(j2));
}
if ((1 | (j - 1)) == Long.MAX_VALUE) {
return infinityOfSign(j);
}
return saturatingFiniteDiff(j, j2, unit);
}
private static final long saturatingFiniteDiff(long j, long j2, DurationUnit durationUnit) {
long j3 = j - j2;
if (((j3 ^ j) & (~(j3 ^ j2))) < 0) {
if (durationUnit.compareTo(DurationUnit.MILLISECONDS) < 0) {
long convertDurationUnit = DurationUnitKt.convertDurationUnit(1L, DurationUnit.MILLISECONDS, durationUnit);
long j4 = (j / convertDurationUnit) - (j2 / convertDurationUnit);
long j5 = (j % convertDurationUnit) - (j2 % convertDurationUnit);
Duration.Companion companion = Duration.INSTANCE;
return Duration.m7060plusLRDsOJo(DurationKt.toDuration(j4, DurationUnit.MILLISECONDS), DurationKt.toDuration(j5, durationUnit));
}
return Duration.m7077unaryMinusUwyO8pc(infinityOfSign(j3));
}
return DurationKt.toDuration(j3, durationUnit);
}
}