CY
The CY structure is useful for calculations involving money, or for any fixed-point calculation where accuracy is particularly important.
using System;
using System.CodeDom.Compiler;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Windows.Win32.System.Com
{
[StructLayout(LayoutKind.Explicit)]
[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.151+58e949951d.RR")]
internal struct CY : IEquatable<CY>
{
[GeneratedCode("Microsoft.Windows.CsWin32", "0.3.151+58e949951d.RR")]
internal struct _Anonymous_e__Struct
{
internal uint Lo;
internal int Hi;
}
[FieldOffset(0)]
internal _Anonymous_e__Struct Anonymous;
[FieldOffset(0)]
internal long int64;
[IsReadOnly]
public bool Equals(CY other)
{
return int64 == other.int64;
}
[IsReadOnly]
[NullableContext(2)]
public override bool Equals(object obj)
{
if (obj is CY) {
CY other = (CY)obj;
return Equals(other);
}
return false;
}
[IsReadOnly]
public override int GetHashCode()
{
return int64.GetHashCode();
}
public static bool operator ==(CY left, CY right)
{
return left.Equals(right);
}
public static bool operator !=(CY left, CY right)
{
return !left.Equals(right);
}
public static explicit operator decimal(CY value)
{
return decimal.FromOACurrency(value.int64);
}
public static explicit operator CY(decimal value)
{
CY result = default(CY);
result.int64 = decimal.ToOACurrency(value);
return result;
}
public static explicit operator float(CY value)
{
return (float)value.int64 / 10000;
}
public static explicit operator CY(float value)
{
CY result = default(CY);
result.int64 = (long)(value * 10000);
return result;
}
}
}