Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some TODO #5213 comments #100954

Closed
wants to merge 8 commits into from
33 changes: 16 additions & 17 deletions src/libraries/System.Private.CoreLib/src/System/DateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1406,36 +1406,35 @@ internal void GetDate(out int year, out int month, out int day)
internal void GetTime(out int hour, out int minute, out int second)
{
ulong seconds = UTicks / TicksPerSecond;
ulong minutes = seconds / 60;
second = (int)(seconds - (minutes * 60));
ulong hours = minutes / 60;
minute = (int)(minutes - (hours * 60));
(ulong minutes, ulong uSecond) = Math.DivRem(seconds, 60);
second = (int)uSecond;
(ulong hours, ulong uMinute) = Math.DivRem(minutes, 60);
minute = (int)uMinute;
hour = (int)((uint)hours % 24);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void GetTime(out int hour, out int minute, out int second, out int millisecond)
{
ulong milliseconds = UTicks / TicksPerMillisecond;
ulong seconds = milliseconds / 1000;
millisecond = (int)(milliseconds - (seconds * 1000));
ulong minutes = seconds / 60;
second = (int)(seconds - (minutes * 60));
ulong hours = minutes / 60;
minute = (int)(minutes - (hours * 60));
(ulong seconds, ulong uMillisecond) = Math.DivRem(milliseconds, 1000);
millisecond = (int)uMillisecond;
(ulong minutes, ulong uSecond) = Math.DivRem(seconds, 60);
second = (int)uSecond;
(ulong hours, ulong uMinute) = Math.DivRem(minutes, 60);
minute = (int)uMinute;
hour = (int)((uint)hours % 24);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void GetTimePrecise(out int hour, out int minute, out int second, out int tick)
{
ulong ticks = UTicks;
ulong seconds = ticks / TicksPerSecond;
tick = (int)(ticks - (seconds * TicksPerSecond));
ulong minutes = seconds / 60;
second = (int)(seconds - (minutes * 60));
ulong hours = minutes / 60;
minute = (int)(minutes - (hours * 60));
(ulong seconds, ulong uTick) = Math.DivRem(UTicks, TicksPerSecond);
tick = (int)uTick;
(ulong minutes, ulong uSecond) = Math.DivRem(seconds, 60);
second = (int)uSecond;
(ulong hours, ulong uMinute) = Math.DivRem(minutes, 60);
minute = (int)uMinute;
hour = (int)((uint)hours % 24);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ private static uint Div96By32(ref Buf12 bufNum, uint den)
private static bool Div96ByConst(ref ulong high64, ref uint low, uint pow)
{
#if TARGET_64BIT
// TODO: https://github.com/dotnet/runtime/issues/5213
ulong div64 = high64 / pow;
uint div = (uint)((((high64 - div64 * pow) << 32) + low) / pow);
if (low == div * pow)
Expand Down Expand Up @@ -675,6 +676,7 @@ private static unsafe uint DivByConst(uint* result, uint hiRes, out uint quotien
for (uint i = hiRes - 1; (int)i >= 0; i--)
{
#if TARGET_64BIT
// TODO: https://github.com/dotnet/runtime/issues/5213
ulong num = result[i] + ((ulong)remainder << 32);
remainder = (uint)num - (result[i] = (uint)(num / power)) * power;
#else
Expand Down Expand Up @@ -710,6 +712,7 @@ private static int OverflowUnscale(ref Buf12 bufQuo, int scale, bool sticky)
Debug.Assert(bufQuo.U2 == 0);

// We have overflown, so load the high bit with a one.
// TODO: https://github.com/dotnet/runtime/issues/5213
const ulong highbit = 1UL << 32;
bufQuo.U2 = (uint)(highbit / 10);
ulong tmp = ((highbit % 10) << 32) + bufQuo.U1;
Expand Down Expand Up @@ -1090,6 +1093,7 @@ internal static unsafe void DecAddSub(ref DecCalc d1, ref DecCalc d2, bool sign)
Number.ThrowOverflowException(SR.Overflow_Decimal);
flags -= 1 << ScaleShift;

// TODO: https://github.com/dotnet/runtime/issues/5213
const uint den = 10;
ulong num = high + (1UL << 32);
high = (uint)(num / den);
Expand Down Expand Up @@ -1776,6 +1780,7 @@ internal static void VarDecFromR8(double input, out DecCalc result)
if (lmax > 14)
lmax = 14;

// TODO: https://github.com/dotnet/runtime/issues/5213
if ((byte)mant == 0 && lmax >= 8)
{
const uint den = 100000000;
Expand Down Expand Up @@ -2349,6 +2354,7 @@ internal static void InternalRound(ref DecCalc d, uint scale, MidpointRounding m
{
scale -= MaxInt32Scale;

// TODO: https://github.com/dotnet/runtime/issues/5213
const uint divisor = TenToPowerNine;
uint n = d.uhi;
if (n == 0)
Expand Down Expand Up @@ -2463,6 +2469,7 @@ internal static uint DecDivMod1E9(ref DecCalc value)
value.uhi = (uint)(div64 >> 32);
value.umid = (uint)div64;

// TODO: https://github.com/dotnet/runtime/issues/5213
ulong num = ((high64 - (uint)div64 * TenToPowerNine) << 32) + value.ulo;
uint div = (uint)(num / TenToPowerNine);
value.ulo = div;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ public static void Divide(ReadOnlySpan<uint> left, uint right, Span<uint> quotie
for (int i = left.Length - 1; i >= 0; i--)
{
ulong value = (carry << 32) | left[i];
ulong digit = value / right;
(ulong digit, carry) = Math.DivRem(value, right);
quotient[i] = (uint)digit;
carry = value - digit * right;
}
remainder = (uint)carry;
}
Expand All @@ -40,9 +39,8 @@ public static void Divide(ReadOnlySpan<uint> left, uint right, Span<uint> quotie
for (int i = left.Length - 1; i >= 0; i--)
{
ulong value = (carry << 32) | left[i];
ulong digit = value / right;
(ulong digit, carry) = Math.DivRem(value, right);
quotient[i] = (uint)digit;
carry = value - digit * right;
}
}

Expand Down
Loading