From 522ceb16b448746707f204bdb767754ec0642db3 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Thu, 18 Aug 2016 09:37:06 +0100 Subject: [PATCH] Inital interface for Dec64 Ref: https://github.com/dotnet/corefx/issues/10951 See: https://github.com/douglascrockford/DEC64 --- corefxlab.sln | 7 + .../System.Numerics.Dec64.xproj | 20 + .../System/Numerics/Dec64.Comparable.cs | 52 +++ .../System/Numerics/Dec64.Formattable.cs | 64 ++++ .../System/Numerics/Dec64.Maths.cs | 129 +++++++ .../System/Numerics/Dec64.Operators.cs | 344 ++++++++++++++++++ .../System/Numerics/Dec64.cs | 69 ++++ src/System.Numerics.Dec64/project.json | 36 ++ 8 files changed, 721 insertions(+) create mode 100644 src/System.Numerics.Dec64/System.Numerics.Dec64.xproj create mode 100644 src/System.Numerics.Dec64/System/Numerics/Dec64.Comparable.cs create mode 100644 src/System.Numerics.Dec64/System/Numerics/Dec64.Formattable.cs create mode 100644 src/System.Numerics.Dec64/System/Numerics/Dec64.Maths.cs create mode 100644 src/System.Numerics.Dec64/System/Numerics/Dec64.Operators.cs create mode 100644 src/System.Numerics.Dec64/System/Numerics/Dec64.cs create mode 100644 src/System.Numerics.Dec64/project.json diff --git a/corefxlab.sln b/corefxlab.sln index 1de6355704a..187e18ca2da 100644 --- a/corefxlab.sln +++ b/corefxlab.sln @@ -73,6 +73,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "System.Text.Primitives.Test EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "System.Text.Primitives", "src\System.Text.Primitives\System.Text.Primitives.xproj", "{80E6332B-DC83-4DFC-9C19-8D89E988BA4E}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "System.Numerics.Dec64", "src\System.Numerics.Dec64\System.Numerics.Dec64.xproj", "{329B9BE5-3F34-42A2-9E8C-D7BDD6B1EE55}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -211,6 +213,10 @@ Global {80E6332B-DC83-4DFC-9C19-8D89E988BA4E}.Debug|Any CPU.Build.0 = Debug|Any CPU {80E6332B-DC83-4DFC-9C19-8D89E988BA4E}.Release|Any CPU.ActiveCfg = Release|Any CPU {80E6332B-DC83-4DFC-9C19-8D89E988BA4E}.Release|Any CPU.Build.0 = Release|Any CPU + {329B9BE5-3F34-42A2-9E8C-D7BDD6B1EE55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {329B9BE5-3F34-42A2-9E8C-D7BDD6B1EE55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {329B9BE5-3F34-42A2-9E8C-D7BDD6B1EE55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {329B9BE5-3F34-42A2-9E8C-D7BDD6B1EE55}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -249,5 +255,6 @@ Global {D5281344-D323-4E13-8BC7-4F39814AD4A6} = {3079E458-D0E6-4F99-8CAB-80011D35C7DA} {67B42C20-D98A-420B-82C0-04AFD963E650} = {3079E458-D0E6-4F99-8CAB-80011D35C7DA} {80E6332B-DC83-4DFC-9C19-8D89E988BA4E} = {4B000021-5278-4F2A-B734-DE49F55D4024} + {329B9BE5-3F34-42A2-9E8C-D7BDD6B1EE55} = {4B000021-5278-4F2A-B734-DE49F55D4024} EndGlobalSection EndGlobal diff --git a/src/System.Numerics.Dec64/System.Numerics.Dec64.xproj b/src/System.Numerics.Dec64/System.Numerics.Dec64.xproj new file mode 100644 index 00000000000..9ff310295de --- /dev/null +++ b/src/System.Numerics.Dec64/System.Numerics.Dec64.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + 329b9be5-3f34-42a2-9e8c-d7bdd6b1ee55 + System.Numerics + .\obj + .\bin\ + + + + 2.0 + + + diff --git a/src/System.Numerics.Dec64/System/Numerics/Dec64.Comparable.cs b/src/System.Numerics.Dec64/System/Numerics/Dec64.Comparable.cs new file mode 100644 index 00000000000..e7651174ffa --- /dev/null +++ b/src/System.Numerics.Dec64/System/Numerics/Dec64.Comparable.cs @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace System.Numerics +{ + public partial struct Dec64 : IComparable, IFormattable, IComparable, IEquatable + { + public bool Equals(Dec64 other) => _value == other._value; + + public bool Equals(long other) + { + return default(bool); + } + + public override bool Equals(object obj) + { + return default(bool); + } + + public bool Equals(ulong other) + { + return default(bool); + } + + public static int Compare(Dec64 left, Dec64 right) + { + return default(int); + } + + public int CompareTo(long other) + { + return default(int); + } + + public int CompareTo(Dec64 other) + { + + return default(int); + } + + public int CompareTo(ulong other) + { + return default(int); + } + + int System.IComparable.CompareTo(object obj) + { + return default(int); + } + } +} diff --git a/src/System.Numerics.Dec64/System/Numerics/Dec64.Formattable.cs b/src/System.Numerics.Dec64/System/Numerics/Dec64.Formattable.cs new file mode 100644 index 00000000000..a3be67db353 --- /dev/null +++ b/src/System.Numerics.Dec64/System/Numerics/Dec64.Formattable.cs @@ -0,0 +1,64 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace System.Numerics +{ + public partial struct Dec64 : IComparable, IFormattable, IComparable, IEquatable + { + public static bool TryParse(string value, System.Globalization.NumberStyles style, System.IFormatProvider provider, out Dec64 result) + { + result = default(Dec64); return default(bool); + } + + public static bool TryParse(string value, out Dec64 result) + { + result = default(Dec64); return default(bool); + } + + public static Dec64 Parse(string value) + { + return default(Dec64); + } + + public static Dec64 Parse(string value, System.Globalization.NumberStyles style) + { + return default(Dec64); + } + + public static Dec64 Parse(string value, System.Globalization.NumberStyles style, System.IFormatProvider provider) + { + return default(Dec64); + } + + public static Dec64 Parse(string value, System.IFormatProvider provider) + { + return default(Dec64); + } + + public byte[] ToByteArray() + { + return default(byte[]); + } + + public override string ToString() + { + return default(string); + } + + public string ToString(System.IFormatProvider provider) + { + return default(string); + } + + public string ToString(string format) + { + return default(string); + } + + public string ToString(string format, System.IFormatProvider provider) + { + return default(string); + } + } +} diff --git a/src/System.Numerics.Dec64/System/Numerics/Dec64.Maths.cs b/src/System.Numerics.Dec64/System/Numerics/Dec64.Maths.cs new file mode 100644 index 00000000000..2280b4c9fde --- /dev/null +++ b/src/System.Numerics.Dec64/System/Numerics/Dec64.Maths.cs @@ -0,0 +1,129 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace System.Numerics +{ + public partial struct Dec64 : IComparable, IFormattable, IComparable, IEquatable + { + public bool IsEven + { + get + { + return default(bool); + } + } + + public bool IsOne + { + get + { + return default(bool); + } + } + + public bool IsPowerOfTwo + { + get + { + return default(bool); + } + } + + public bool IsZero + { + get + { + return default(bool); + } + } + + public int Sign + { + get + { + return default(int); + } + } + + public static Dec64 Abs(Dec64 value) + { + return default(Dec64); + } + + public static Dec64 Add(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static Dec64 Divide(Dec64 dividend, Dec64 divisor) + { + return default(Dec64); + } + + public static Dec64 DivRem(Dec64 dividend, Dec64 divisor, out Dec64 remainder) + { + remainder = default(Dec64); return default(Dec64); + } + + public static Dec64 GreatestCommonDivisor(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static double Log(Dec64 value) + { + return default(double); + } + + public static double Log(Dec64 value, double baseValue) + { + return default(double); + } + + public static double Log10(Dec64 value) + { + return default(double); + } + + public static Dec64 Max(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static Dec64 Min(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static Dec64 ModPow(Dec64 value, Dec64 exponent, Dec64 modulus) + { + return default(Dec64); + } + + public static Dec64 Multiply(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static Dec64 Negate(Dec64 value) + { + return default(Dec64); + } + + public static Dec64 Pow(Dec64 value, int exponent) + { + return default(Dec64); + } + + public static Dec64 Remainder(Dec64 dividend, Dec64 divisor) + { + return default(Dec64); + } + + public static Dec64 Subtract(Dec64 left, Dec64 right) + { + return default(Dec64); + } + } +} diff --git a/src/System.Numerics.Dec64/System/Numerics/Dec64.Operators.cs b/src/System.Numerics.Dec64/System/Numerics/Dec64.Operators.cs new file mode 100644 index 00000000000..e7c6d801df6 --- /dev/null +++ b/src/System.Numerics.Dec64/System/Numerics/Dec64.Operators.cs @@ -0,0 +1,344 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace System.Numerics +{ + public partial struct Dec64 : IComparable, IFormattable, IComparable, IEquatable + { + public static Dec64 operator +(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static Dec64 operator &(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static Dec64 operator |(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static Dec64 operator --(Dec64 value) + { + return default(Dec64); + } + + public static Dec64 operator /(Dec64 dividend, Dec64 divisor) + { + return default(Dec64); + } + + public static bool operator ==(long left, Dec64 right) + { + return default(bool); + } + + public static bool operator ==(Dec64 left, long right) + { + return default(bool); + } + + public static bool operator ==(Dec64 left, Dec64 right) + { + return default(bool); + } + + public static bool operator ==(Dec64 left, ulong right) + { + return default(bool); + } + + public static bool operator ==(ulong left, Dec64 right) + { + return default(bool); + } + + public static Dec64 operator ^(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static explicit operator Dec64(decimal value) + { + return default(Dec64); + } + + public static explicit operator Dec64(double value) + { + return default(Dec64); + } + + public static explicit operator byte(Dec64 value) + { + return default(byte); + } + + public static explicit operator decimal(Dec64 value) + { + return default(decimal); + } + + public static explicit operator double(Dec64 value) + { + return default(double); + } + + public static explicit operator short(Dec64 value) + { + return default(short); + } + + public static explicit operator int(Dec64 value) + { + return default(int); + } + + public static explicit operator long(Dec64 value) + { + return default(long); + } + + public static explicit operator sbyte(Dec64 value) + { + return default(sbyte); + } + + public static explicit operator float(Dec64 value) + { + return default(float); + } + + public static explicit operator ushort(Dec64 value) + { + return default(ushort); + } + + public static explicit operator uint(Dec64 value) + { + return default(uint); + } + + public static explicit operator ulong(Dec64 value) + { + return default(ulong); + } + + public static explicit operator Dec64(float value) + { + return default(Dec64); + } + + public static bool operator >(long left, Dec64 right) + { + return default(bool); + } + + public static bool operator >(Dec64 left, long right) + { + return default(bool); + } + + public static bool operator >(Dec64 left, Dec64 right) + { + return default(bool); + } + + public static bool operator >(Dec64 left, ulong right) + { + return default(bool); + } + + public static bool operator >(ulong left, Dec64 right) + { + return default(bool); + } + + public static bool operator >=(long left, Dec64 right) + { + return default(bool); + } + + public static bool operator >=(Dec64 left, long right) + { + return default(bool); + } + + public static bool operator >=(Dec64 left, Dec64 right) + { + return default(bool); + } + + public static bool operator >=(Dec64 left, ulong right) + { + return default(bool); + } + + public static bool operator >=(ulong left, Dec64 right) + { + return default(bool); + } + + public static implicit operator Dec64(byte value) + { + return default(Dec64); + } + + public static implicit operator Dec64(short value) + { + return default(Dec64); + } + + public static implicit operator Dec64(int value) + { + return default(Dec64); + } + + public static implicit operator Dec64(long value) + { + return default(Dec64); + } + + public static implicit operator Dec64(sbyte value) + { + return default(Dec64); + } + + public static implicit operator Dec64(ushort value) + { + return default(Dec64); + } + + public static implicit operator Dec64(uint value) + { + return default(Dec64); + } + + public static implicit operator Dec64(ulong value) + { + return default(Dec64); + } + + public static Dec64 operator ++(Dec64 value) + { + return default(Dec64); + } + + public static bool operator !=(long left, Dec64 right) + { + return default(bool); + } + + public static bool operator !=(Dec64 left, long right) + { + return default(bool); + } + + public static bool operator !=(Dec64 left, Dec64 right) + { + return default(bool); + } + + public static bool operator !=(Dec64 left, ulong right) + { + return default(bool); + } + + public static bool operator !=(ulong left, Dec64 right) + { + return default(bool); + } + + public static Dec64 operator <<(Dec64 value, int shift) + { + return default(Dec64); + } + + public static bool operator <(long left, Dec64 right) + { + return default(bool); + } + + public static bool operator <(Dec64 left, long right) + { + return default(bool); + } + + public static bool operator <(Dec64 left, Dec64 right) + { + return default(bool); + } + + public static bool operator <(Dec64 left, ulong right) + { + return default(bool); + } + + public static bool operator <(ulong left, Dec64 right) + { + return default(bool); + } + + public static bool operator <=(long left, Dec64 right) + { + return default(bool); + } + + public static bool operator <=(Dec64 left, long right) + { + return default(bool); + } + + public static bool operator <=(Dec64 left, Dec64 right) + { + return default(bool); + } + + public static bool operator <=(Dec64 left, ulong right) + { + return default(bool); + } + + public static bool operator <=(ulong left, Dec64 right) + { + return default(bool); + } + + public static Dec64 operator %(Dec64 dividend, Dec64 divisor) + { + return default(Dec64); + } + + public static Dec64 operator *(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static Dec64 operator ~(Dec64 value) + { + return default(Dec64); + } + + public static Dec64 operator >>(Dec64 value, int shift) + { + return default(Dec64); + } + + public static Dec64 operator -(Dec64 left, Dec64 right) + { + return default(Dec64); + } + + public static Dec64 operator -(Dec64 value) + { + return default(Dec64); + } + + public static Dec64 operator +(Dec64 value) + { + return default(Dec64); + } + } +} diff --git a/src/System.Numerics.Dec64/System/Numerics/Dec64.cs b/src/System.Numerics.Dec64/System/Numerics/Dec64.cs new file mode 100644 index 00000000000..cc829736b56 --- /dev/null +++ b/src/System.Numerics.Dec64/System/Numerics/Dec64.cs @@ -0,0 +1,69 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Runtime.InteropServices; + +namespace System.Numerics +{ + /// + /// Represents a decimal floating point value as defined by Douglas Crockford in https://github.com/douglascrockford/DEC64 + /// + [StructLayout(LayoutKind.Sequential)] + public partial struct Dec64 : IComparable, IFormattable, IComparable, IEquatable + { + public readonly static Dec64 NaN = new Dec64() { _value = 0x80UL }; + public readonly static Dec64 Zero = default(Dec64); + public readonly static Dec64 One = new Dec64() { _value = 0x100UL }; + public readonly static Dec64 True = new Dec64() { _value = 0x380UL }; + public readonly static Dec64 False = new Dec64() { _value = 0x280UL }; + public readonly static Dec64 MinusOne = new Dec64() {_value = 0xFFFFFFFFFFFFFF00UL }; + + private ulong _value; + + public Dec64(byte[] value) + { + throw new NotImplementedException(); + } + + public Dec64(decimal value) + { + throw new NotImplementedException(); + } + + public Dec64(double value) + { + throw new NotImplementedException(); + } + + public Dec64(int value) + { + throw new NotImplementedException(); + } + + public Dec64(long value) + { + throw new NotImplementedException(); + } + + public Dec64(float value) + { + throw new NotImplementedException(); + } + + public Dec64(uint value) + { + throw new NotImplementedException(); + } + + public Dec64(ulong value) + { + throw new NotImplementedException(); + } + + public override int GetHashCode() + { + return default(int); + } + } +} diff --git a/src/System.Numerics.Dec64/project.json b/src/System.Numerics.Dec64/project.json new file mode 100644 index 00000000000..15c2fc8f8c1 --- /dev/null +++ b/src/System.Numerics.Dec64/project.json @@ -0,0 +1,36 @@ +{ + "name": "System.Numerics.Dec64", + "version": "0.1.0-*", + "description": "64 bit decimal floating point value", + "authors": [ + ".NET Foundation and contributors" + ], + + "copyright": ".NET Foundation, All rights reserved", + "packOptions": { + "tags": [ + ".NET 64 bit decimal floating point value" + ], + "releaseNotes": "Pre-release package, for testing only", + "licenseUrl": "http://go.microsoft.com/fwlink/?LinkId=329770", + "iconUrl": "http://go.microsoft.com/fwlink/?LinkID=288859", + "projectUrl": "https://github.com/dotnet/corefxlab", + "requireLicenseAcceptance": true + }, + + "buildOptions": { + "keyFile": "../../tools/Key.snk" + }, + + "dependencies": { + "System.Runtime": "4.0.0", + "System.Runtime.InteropServices": "4.0.0", + "System.Diagnostics.Debug": "4.0.0" + }, + + "frameworks": { + "netstandard1.0": { + "imports": [ "dotnet5.1" ] + } + } +}