C# Tutorials - Herong's Tutorial Examples - v3.32, by Herong Yang
The "decimal" Data Type
This section describes the 'decimal' data type for floating-point values. 'decimal' uses a 128-bit storage size.
Comparing with Java, C# has a very interesting new date type called: decimal.
The "decimal" data type for floating-point values with a storage size that doubles the storage size of the "double" data type. See the storage size and precision range comparisons with "float", "double" and "decimal":
The following code will show you this:
// Decimals.cs // Copyright (c) 2006 HerongYang.com. All Rights Reserved. class Decimals { public static void Main() { float f; double d; decimal m; f = 10.0f/3.0f; d = 10.0d/3.0d; m = 10.0m/3.0m; System.Console.WriteLine("Float 10/3 = {0}", f); System.Console.WriteLine("Double 10/3 = {0}", d); System.Console.WriteLine("Decimal 10/3 = {0}", m); } }
Output:
Float 10/3 = 3.333333 Double 10/3 = 3.33333333333333 Decimal 10/3 = 3.3333333333333333333333333333
Table of Contents
Logical Expressions and Conditional Statements
Simple Types Are "struct" Types
Visual C# 2010 Express Edition
C# Compiler and Intermediate Language
Compiling C# Source Code Files
MSBuild - Microsoft Build Engine
System.Diagnostics.FileVersionInfo Class
WPF - Windows Presentation Foundation