Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 140 additions & 65 deletions mcs/class/corlib/corert/Decimal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,9 @@ void IDeserializationCallback.OnDeserialization(Object sender)
throw new SerializationException(SR.Overflow_Decimal);
}

// Constructs a Decimal from its constituent parts.
private Decimal(ulong ulomidLE, uint hi, uint flags)
#if __MonoCS__
: this()
#endif
private Decimal(ref Decimal d, uint flags)
{
this.ulomidLE = ulomidLE;
this.uhi = hi;
this = d;
this.uflags = flags;
}

Expand All @@ -350,7 +345,7 @@ private Decimal(ulong ulomidLE, uint hi, uint flags)
//
internal static Decimal Abs(ref Decimal d)
{
return new Decimal(d.ulomidLE, d.uhi, d.uflags & ~SignMask);
return new Decimal(ref d, d.uflags & ~SignMask);
}


Expand Down Expand Up @@ -665,7 +660,7 @@ public static Decimal Multiply(Decimal d1, Decimal d2)
//
public static Decimal Negate(Decimal d)
{
return new Decimal(d.ulomidLE, d.uhi, d.uflags ^ SignMask);
return new Decimal(ref d, d.uflags ^ SignMask);
}

// Rounds a Decimal value to a given number of decimal places. The value
Expand Down Expand Up @@ -1219,13 +1214,23 @@ internal int Scale

private ulong Low64
{
#if BIGENDIAN && !MONO
get { return ((ulong)umid << 32) | ulo; }
set { umid = (uint)(value >> 32); ulo = (uint)value; }
#else
get => ulomidLE;
set => ulomidLE = value;
#endif
get
{
if (BitConverter.IsLittleEndian)
return ulomidLE;
else
return ((ulong)umid << 32) | ulo;
}
set
{
if (BitConverter.IsLittleEndian)
ulomidLE = value;
else
{
umid = (uint)(value >> 32);
ulo = (uint)value;
}
}
}

#region APIs need by number formatting.
Expand Down Expand Up @@ -3725,27 +3730,47 @@ private struct Buf12

public ulong Low64
{
#if BIGENDIAN && !MONO
get => ((ulong)U1 << 32) | U0;
set { U1 = (uint)(value >> 32); U0 = (uint)value; }
#else
get => ulo64LE;
set => ulo64LE = value;
#endif
get
{
if (BitConverter.IsLittleEndian)
return ulo64LE;
else
return ((ulong)U1 << 32) | U0;
}
set
{
if (BitConverter.IsLittleEndian)
ulo64LE = value;
else
{
U1 = (uint)(value >> 32);
U0 = (uint)value;
}
}
}

/// <summary>
/// U1-U2 combined (overlaps with Low64)
/// </summary>
public ulong High64
{
#if BIGENDIAN && !MONO
get => ((ulong)U2 << 32) | U1;
set { U2 = (uint)(value >> 32); U1 = (uint)value; }
#else
get => uhigh64LE;
set => uhigh64LE = value;
#endif
get
{
if (BitConverter.IsLittleEndian)
return uhigh64LE;
else
return ((ulong)U2 << 32) | U1;
}
set
{
if (BitConverter.IsLittleEndian)
uhigh64LE = value;
else
{
U2 = (uint)(value >> 32);
U1 = (uint)value;
}
}
}
}

Expand All @@ -3768,24 +3793,44 @@ private struct Buf16

public ulong Low64
{
#if BIGENDIAN && !MONO
get => ((ulong)U1 << 32) | U0;
set { U1 = (uint)(value >> 32); U0 = (uint)value; }
#else
get => ulo64LE;
set => ulo64LE = value;
#endif
get
{
if (BitConverter.IsLittleEndian)
return ulo64LE;
else
return ((ulong)U1 << 32) | U0;
}
set
{
if (BitConverter.IsLittleEndian)
ulo64LE = value;
else
{
U1 = (uint)(value >> 32);
U0 = (uint)value;
}
}
}

public ulong High64
{
#if BIGENDIAN && !MONO
get => ((ulong)U3 << 32) | U2;
set { U3 = (uint)(value >> 32); U2 = (uint)value; }
#else
get => uhigh64LE;
set => uhigh64LE = value;
#endif
get
{
if (BitConverter.IsLittleEndian)
return uhigh64LE;
else
return ((ulong)U3 << 32) | U2;
}
set
{
if (BitConverter.IsLittleEndian)
uhigh64LE = value;
else
{
U3 = (uint)(value >> 32);
U2 = (uint)value;
}
}
}
}

Expand Down Expand Up @@ -3814,35 +3859,65 @@ private struct Buf24

public ulong Low64
{
#if BIGENDIAN && !MONO
get => ((ulong)U1 << 32) | U0;
set { U1 = (uint)(value >> 32); U0 = (uint)value; }
#else
get => ulo64LE;
set => ulo64LE = value;
#endif
get
{
if (BitConverter.IsLittleEndian)
return ulo64LE;
else
return ((ulong)U1 << 32) | U0;
}
set
{
if (BitConverter.IsLittleEndian)
ulo64LE = value;
else
{
U1 = (uint)(value >> 32);
U0 = (uint)value;
}
}
}

public ulong Mid64
{
#if BIGENDIAN && !MONO
get => ((ulong)U3 << 32) | U2;
set { U3 = (uint)(value >> 32); U2 = (uint)value; }
#else
get => umid64LE;
set => umid64LE = value;
#endif
get
{
if (BitConverter.IsLittleEndian)
return umid64LE;
else
return ((ulong)U3 << 32) | U2;
}
set
{
if (BitConverter.IsLittleEndian)
umid64LE = value;
else
{
U3 = (uint)(value >> 32);
U2 = (uint)value;
}
}
}

public ulong High64
{
#if BIGENDIAN && !MONO
get => ((ulong)U5 << 32) | U4;
set { U5 = (uint)(value >> 32); U4 = (uint)value; }
#else
get => uhigh64LE;
set => uhigh64LE = value;
#endif
get
{
if (BitConverter.IsLittleEndian)
return uhigh64LE;
else
return ((ulong)U5 << 32) | U4;
}
set
{
if (BitConverter.IsLittleEndian)
uhigh64LE = value;
else
{
U5 = (uint)(value >> 32);
U4 = (uint)value;
}
}
}

public int Length => 6;
Expand Down