Skip to content

Commit 242ef14

Browse files
authored
Add decimal data type. (#1)
Add decimal data type.
1 parent 1cfe32a commit 242ef14

13 files changed

Lines changed: 323 additions & 2 deletions

File tree

Addition/Addition.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ static void Main(string[] args)
3737
Console.WriteLine("Exception Message: {0}", ex.Message);
3838
}
3939
try
40+
{
41+
decimal v1 = decimal.MaxValue;
42+
decimal v2 = decimal.MaxValue;
43+
Console.WriteLine("Type: {0}", v1.GetType().Name);
44+
Console.WriteLine("1. Value of v1 = {0}", v1);
45+
v1 = v2+v1;
46+
Console.WriteLine("2. Value of v1 = {0}", v1);
47+
}
48+
catch (Exception ex)
49+
{
50+
Console.WriteLine("Exception Message: {0}", ex.Message);
51+
}
52+
try
4053
{
4154
uint v1 = uint.MaxValue;
4255
uint v2 = uint.MaxValue;

Division/Division.cs

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
namespace MathFun
2+
{
3+
using System;
4+
class Division
5+
{
6+
static void Main(string[] args)
7+
{
8+
try
9+
{
10+
float de = 0;
11+
float nu = 1;
12+
Console.WriteLine("Type: {0}", de.GetType().Name);
13+
Console.WriteLine("1. Value of de = {0}", de);
14+
de = nu/de;
15+
Console.WriteLine("2. Value of de = {0}", de);
16+
}
17+
catch (Exception ex)
18+
{
19+
Console.WriteLine("Exception Message: {0}", ex.Message);
20+
}
21+
try
22+
{
23+
double de = 0;
24+
double nu = 1;
25+
Console.WriteLine("Type: {0}", de.GetType().Name);
26+
Console.WriteLine("1. Value of de = {0}", de);
27+
de = nu/de;
28+
Console.WriteLine("2. Value of de = {0}", de);
29+
}
30+
catch (Exception ex)
31+
{
32+
Console.WriteLine("Exception Message: {0}", ex.Message);
33+
}
34+
try
35+
{
36+
decimal de = 0;
37+
decimal nu = 1;
38+
Console.WriteLine("Type: {0}", de.GetType().Name);
39+
Console.WriteLine("1. Value of de = {0}", de);
40+
de = nu/de;
41+
Console.WriteLine("2. Value of de = {0}", de);
42+
}
43+
catch (Exception ex)
44+
{
45+
Console.WriteLine("Exception Message: {0}", ex.Message);
46+
}
47+
try
48+
{
49+
uint de = 0;
50+
uint nu = 1;
51+
Console.WriteLine("Type: {0}", de.GetType().Name);
52+
Console.WriteLine("1. Value of de = {0}", de);
53+
de = nu/de;
54+
Console.WriteLine("2. Value of de = {0}", de);
55+
}
56+
catch (Exception ex)
57+
{
58+
Console.WriteLine("Exception Message: {0}", ex.Message);
59+
}
60+
try
61+
{
62+
int de = 0;
63+
int nu = 1;
64+
Console.WriteLine("Type: {0}", de.GetType().Name);
65+
Console.WriteLine("1. Value of de = {0}", de);
66+
de = nu/de;
67+
Console.WriteLine("2. Value of de = {0}", de);
68+
}
69+
catch (Exception ex)
70+
{
71+
Console.WriteLine("Exception Message: {0}", ex.Message);
72+
}
73+
try
74+
{
75+
short de = 0;
76+
short nu = 1;
77+
Console.WriteLine("Type: {0}", de.GetType().Name);
78+
Console.WriteLine("1. Value of de = {0}", de);
79+
de = (short)(nu/de);
80+
Console.WriteLine("2. Value of de = {0}", de);
81+
}
82+
catch (Exception ex)
83+
{
84+
Console.WriteLine("Exception Message: {0}", ex.Message);
85+
}
86+
try
87+
{
88+
ushort de = 0;
89+
ushort nu = 1;
90+
Console.WriteLine("Type: {0}", de.GetType().Name);
91+
Console.WriteLine("1. Value of de = {0}", de);
92+
de = (ushort)(nu/de);
93+
Console.WriteLine("2. Value of de = {0}", de);
94+
}
95+
catch (Exception ex)
96+
{
97+
Console.WriteLine("Exception Message: {0}", ex.Message);
98+
}
99+
try
100+
{
101+
long de = 0;
102+
long nu = 1;
103+
Console.WriteLine("Type: {0}", de.GetType().Name);
104+
Console.WriteLine("1. Value of de = {0}", de);
105+
de = (long)nu/de;
106+
Console.WriteLine("2. Value of de = {0}", de);
107+
}
108+
catch (Exception ex)
109+
{
110+
Console.WriteLine("Exception Message: {0}", ex.Message);
111+
}
112+
try
113+
{
114+
ulong de = 0;
115+
ulong nu = 1;
116+
Console.WriteLine("Type: {0}", de.GetType().Name);
117+
Console.WriteLine("1. Value of de = {0}", de);
118+
de = (ulong)nu/de;
119+
Console.WriteLine("2. Value of de = {0}", de);
120+
}
121+
catch (Exception ex)
122+
{
123+
Console.WriteLine("Exception Message: {0}", ex.Message);
124+
}
125+
try
126+
{
127+
byte de = 0;
128+
byte nu = 1;
129+
Console.WriteLine("Type: {0}", de.GetType().Name);
130+
Console.WriteLine("1. Value of de = {0}", de);
131+
de = (byte)(nu/de);
132+
Console.WriteLine("2. Value of de = {0}", de);
133+
}
134+
catch (Exception ex)
135+
{
136+
Console.WriteLine("Exception Message: {0}", ex.Message);
137+
}
138+
}
139+
}
140+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{1857E1A4-E781-4B07-B011-AE806BFB4CCA}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>MathFun</RootNamespace>
11+
<AssemblyName>Division</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Division.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="App.config" />
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
54+
Other similar extension points exist, see Microsoft.Common.targets.
55+
<Target Name="BeforeBuild">
56+
</Target>
57+
<Target Name="AfterBuild">
58+
</Target>
59+
-->
60+
</Project>

Division/ZeroDivision/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5+
</startup>
6+
</configuration>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Division")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Division")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("1857e1a4-e781-4b07-b011-ae806bfb4cca")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

MathFun.sln

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
44
VisualStudioVersion = 14.0.25123.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02Division", "ZeroDivision\02Division.csproj", "{1857E1A4-E781-4B07-B011-AE806BFB4CCA}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02Division", "Division\02Division.csproj", "{1857E1A4-E781-4B07-B011-AE806BFB4CCA}"
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "01Multiplication", "Multiplication\01Multiplication.csproj", "{409B1EBC-C517-4F25-BAF8-6ECA2D8F6FC9}"
99
EndProject
1010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "03Addition", "Addition\03Addition.csproj", "{73E4B5C9-FE2D-48B2-AC78-65B502DB286F}"
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "04Subtruction", "Subtruction\04Subtruction.csproj", "{D538E16D-F058-4955-8240-6EA1E651A051}"
1313
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7D56DBD8-730C-40A9-9235-BEAEF23545E0}"
15+
ProjectSection(SolutionItems) = preProject
16+
ReadMe.md = ReadMe.md
17+
EndProjectSection
18+
EndProject
1419
Global
1520
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1621
Debug|Any CPU = Debug|Any CPU

0 commit comments

Comments
 (0)