From 012badbd0c1fea4f2b5fd82dc93f6acbeae7d241 Mon Sep 17 00:00:00 2001 From: MironAtHome Date: Tue, 3 Jan 2017 15:53:09 -0800 Subject: [PATCH] Add decimal data type. Add readme.md information Rename ZeroDvision folder to Division --- Addition/Addition.cs | 13 ++ {ZeroDivision => Division}/02Division.csproj | 0 {ZeroDivision => Division}/App.config | 0 Division/Division.cs | 140 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 0 Division/ZeroDivision/02Division.csproj | 60 ++++++++ Division/ZeroDivision/App.config | 6 + .../ZeroDivision}/Division.cs | 0 .../ZeroDivision/Properties/AssemblyInfo.cs | 36 +++++ MathFun.sln | 7 +- Multiplication/Multiplication.cs | 13 ++ ReadMe.md | 37 ++++- Subtruction/Subtruction.cs | 13 ++ 13 files changed, 323 insertions(+), 2 deletions(-) rename {ZeroDivision => Division}/02Division.csproj (100%) rename {ZeroDivision => Division}/App.config (100%) create mode 100644 Division/Division.cs rename {ZeroDivision => Division}/Properties/AssemblyInfo.cs (100%) create mode 100644 Division/ZeroDivision/02Division.csproj create mode 100644 Division/ZeroDivision/App.config rename {ZeroDivision => Division/ZeroDivision}/Division.cs (100%) create mode 100644 Division/ZeroDivision/Properties/AssemblyInfo.cs diff --git a/Addition/Addition.cs b/Addition/Addition.cs index 50d4c48..7608f48 100644 --- a/Addition/Addition.cs +++ b/Addition/Addition.cs @@ -37,6 +37,19 @@ static void Main(string[] args) Console.WriteLine("Exception Message: {0}", ex.Message); } try + { + decimal v1 = decimal.MaxValue; + decimal v2 = decimal.MaxValue; + Console.WriteLine("Type: {0}", v1.GetType().Name); + Console.WriteLine("1. Value of v1 = {0}", v1); + v1 = v2+v1; + Console.WriteLine("2. Value of v1 = {0}", v1); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try { uint v1 = uint.MaxValue; uint v2 = uint.MaxValue; diff --git a/ZeroDivision/02Division.csproj b/Division/02Division.csproj similarity index 100% rename from ZeroDivision/02Division.csproj rename to Division/02Division.csproj diff --git a/ZeroDivision/App.config b/Division/App.config similarity index 100% rename from ZeroDivision/App.config rename to Division/App.config diff --git a/Division/Division.cs b/Division/Division.cs new file mode 100644 index 0000000..ff25e6e --- /dev/null +++ b/Division/Division.cs @@ -0,0 +1,140 @@ +namespace MathFun +{ + using System; + class Division + { + static void Main(string[] args) + { + try + { + float de = 0; + float nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = nu/de; + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try + { + double de = 0; + double nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = nu/de; + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try + { + decimal de = 0; + decimal nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = nu/de; + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try + { + uint de = 0; + uint nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = nu/de; + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try + { + int de = 0; + int nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = nu/de; + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try + { + short de = 0; + short nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = (short)(nu/de); + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try + { + ushort de = 0; + ushort nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = (ushort)(nu/de); + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try + { + long de = 0; + long nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = (long)nu/de; + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try + { + ulong de = 0; + ulong nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = (ulong)nu/de; + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try + { + byte de = 0; + byte nu = 1; + Console.WriteLine("Type: {0}", de.GetType().Name); + Console.WriteLine("1. Value of de = {0}", de); + de = (byte)(nu/de); + Console.WriteLine("2. Value of de = {0}", de); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + } + } +} diff --git a/ZeroDivision/Properties/AssemblyInfo.cs b/Division/Properties/AssemblyInfo.cs similarity index 100% rename from ZeroDivision/Properties/AssemblyInfo.cs rename to Division/Properties/AssemblyInfo.cs diff --git a/Division/ZeroDivision/02Division.csproj b/Division/ZeroDivision/02Division.csproj new file mode 100644 index 0000000..1f66e0f --- /dev/null +++ b/Division/ZeroDivision/02Division.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {1857E1A4-E781-4B07-B011-AE806BFB4CCA} + Exe + Properties + MathFun + Division + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Division/ZeroDivision/App.config b/Division/ZeroDivision/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/Division/ZeroDivision/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ZeroDivision/Division.cs b/Division/ZeroDivision/Division.cs similarity index 100% rename from ZeroDivision/Division.cs rename to Division/ZeroDivision/Division.cs diff --git a/Division/ZeroDivision/Properties/AssemblyInfo.cs b/Division/ZeroDivision/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f1798a9 --- /dev/null +++ b/Division/ZeroDivision/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Division")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Division")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1857e1a4-e781-4b07-b011-ae806bfb4cca")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/MathFun.sln b/MathFun.sln index 5c19a9e..4ed366d 100644 --- a/MathFun.sln +++ b/MathFun.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02Division", "ZeroDivision\02Division.csproj", "{1857E1A4-E781-4B07-B011-AE806BFB4CCA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02Division", "Division\02Division.csproj", "{1857E1A4-E781-4B07-B011-AE806BFB4CCA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01Multiplication", "Multiplication\01Multiplication.csproj", "{409B1EBC-C517-4F25-BAF8-6ECA2D8F6FC9}" EndProject @@ -11,6 +11,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "03Addition", "Addition\03Ad EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "04Subtruction", "Subtruction\04Subtruction.csproj", "{D538E16D-F058-4955-8240-6EA1E651A051}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7D56DBD8-730C-40A9-9235-BEAEF23545E0}" + ProjectSection(SolutionItems) = preProject + ReadMe.md = ReadMe.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Multiplication/Multiplication.cs b/Multiplication/Multiplication.cs index 3fc4287..ac2a0cf 100644 --- a/Multiplication/Multiplication.cs +++ b/Multiplication/Multiplication.cs @@ -32,6 +32,19 @@ static void Main(string[] args) Console.WriteLine("Exception Message: {0}", ex.Message); } try + { + decimal v1 = decimal.MaxValue; + decimal v2 = decimal.MaxValue; + Console.WriteLine("Type: {0}", v1.GetType().Name); + Console.WriteLine("1. Value of v1 = {0}", v1); + v1 = v2 * v1; + Console.WriteLine("2. Value of v1 = {0}", v1); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try { uint v1 = uint.MaxValue; uint v2 = uint.MaxValue; diff --git a/ReadMe.md b/ReadMe.md index ba20ac7..d9b4cac 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1 +1,36 @@ -Math fun +Math fun + + + +ECMA-334 +4th Edition / June 2006 +C# Language Specification + +8.2.1 Predefined types + +Type Description Example +object The ultimate base type of all other types object o = null; +string String type; a string is a sequence of Unicode + code units string s = "hello"; +sbyte 8-bit signed integral type sbyte val = 12; +short 16-bit signed integral type short val = 12; +int 32-bit signed integral type int val = 12; +long 64-bit signed integral type long val1 = 12; + long val2 = 34L; +byte 8-bit unsigned integral type byte val1 = 12; +ushort 16-bit unsigned integral type ushort val1 = 12; +uint 32-bit unsigned integral type uint val1 = 12; + uint val2 = 34U; +ulong 64-bit unsigned integral type ulong val1 = 12; + ulong val2 = 34U; + ulong val3 = 56L; + ulong val4 = 78UL; +float Single-precision floating point type float val = 1.23F; +double Double-precision floating point type double val1 = 1.23; + double val2 = 4.56D; +bool Boolean type; a bool value is either + true or false bool val1 = true; + bool val2 = false; +char Character type; a char value is + a Unicode code unit char val = 'h'; +decimal Precise decimal type with at least 28 significant digits decimal val = 1.23M; This is attempt to systematically account for such cases as division by zero, overflow, underflow, and handling of NaN by predefined C Sharp programming numeric data types. As well as provide for systemic ordered understanding of how CIL .NET programming language will translate and handle each data type and its respective arithmetic operation. In the end this is to better evaluate options and performance of each choice, as application implementation demands in the future. \ No newline at end of file diff --git a/Subtruction/Subtruction.cs b/Subtruction/Subtruction.cs index d1e367e..6185da5 100644 --- a/Subtruction/Subtruction.cs +++ b/Subtruction/Subtruction.cs @@ -32,6 +32,19 @@ static void Main(string[] args) Console.WriteLine("Exception Message: {0}", ex.Message); } try + { + decimal v1 = decimal.MaxValue; + decimal v2 = decimal.MinValue; + Console.WriteLine("Type: {0}", v1.GetType().Name); + Console.WriteLine("1. Value of v1 = {0}", v1); + v1 = v2-v1; + Console.WriteLine("2. Value of v1 = {0}", v1); + } + catch (Exception ex) + { + Console.WriteLine("Exception Message: {0}", ex.Message); + } + try { uint v1 = uint.MaxValue; uint v2 = uint.MinValue;