This documentation is archived and is not being maintained.

Decimal.One Field

Represents the number one (1).

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static readonly decimal One
public static final Decimal One
public static final var One : decimal
Not applicable.

The following code example illustrates the use of the One field.

// Example of the Decimal fields.
using System;

class DecimalFieldsDemo
{
    public static void Main( )
    {
        const string numberFmt = "{0,-25}{1,45:N0}";
        const string exprFmt = "{0,-55}{1,15}";

        Console.WriteLine( 
            "This example of the fields of the Decimal structure " +
            "\ngenerates the following output.\n" );
        Console.WriteLine( numberFmt, "Field or Expression", "Value" );
        Console.WriteLine( numberFmt, "-------------------", "-----" );

        // Display the values of the Decimal fields.
        Console.WriteLine( numberFmt, "Decimal.MaxValue", 
            Decimal.MaxValue );
        Console.WriteLine( numberFmt, "Decimal.MinValue", 
            Decimal.MinValue );
        Console.WriteLine( numberFmt, "Decimal.MinusOne", 
            Decimal.MinusOne );
        Console.WriteLine( numberFmt, "Decimal.One", Decimal.One );
        Console.WriteLine( numberFmt, "Decimal.Zero", Decimal.Zero );
        Console.WriteLine( );

        // Display the values of expressions of the Decimal fields.
        Console.WriteLine( exprFmt, 
            "( Decimal.MinusOne + Decimal.One ) == Decimal.Zero", 
            (Decimal.MinusOne + Decimal.One ) == Decimal.Zero );
        Console.WriteLine( exprFmt, 
            "Decimal.MaxValue + Decimal.MinValue", 
            Decimal.MaxValue + Decimal.MinValue );
        Console.WriteLine( exprFmt, 
            "Decimal.MinValue / Decimal.MaxValue", 
            Decimal.MinValue / Decimal.MaxValue );
        Console.WriteLine( "{0,-40}{1,30}", 
            "100000000000000M / Decimal.MaxValue", 
            100000000000000M / Decimal.MaxValue );
    }
}

/*
This example of the fields of the Decimal structure
generates the following output.

Field or Expression                                              Value
-------------------                                              -----
Decimal.MaxValue                79,228,162,514,264,337,593,543,950,335
Decimal.MinValue               -79,228,162,514,264,337,593,543,950,335
Decimal.MinusOne                                                    -1
Decimal.One                                                          1
Decimal.Zero                                                         0

( Decimal.MinusOne + Decimal.One ) == Decimal.Zero                True
Decimal.MaxValue + Decimal.MinValue                                  0
Decimal.MinValue / Decimal.MaxValue                                 -1
100000000000000M / Decimal.MaxValue     0.0000000000000012621774483536
*/

// Example of the Decimal fields.
import System.* ;

class DecimalFieldsDemo
{
    public static void main(String[] args)
    {
        final System.String numberFmt = "{0,-25}{1,45:N0}";
        final System.String exprFmt = "{0,-55}{1,15}";

        Console.WriteLine(("This example of the fields of the Decimal " 
            + "structure \ngenerates the following output.\n"));
        Console.WriteLine(numberFmt, "Field or Expression", "Value");
        Console.WriteLine(numberFmt, "-------------------", "-----");

        // Display the values of the Decimal fields.
        Console.WriteLine(numberFmt, "Decimal.MaxValue", Decimal.MaxValue);
        Console.WriteLine(numberFmt, "Decimal.MinValue", Decimal.MinValue);
        Console.WriteLine(numberFmt, "Decimal.MinusOne", Decimal.MinusOne);
        Console.WriteLine(numberFmt, "Decimal.One", Decimal.One);
        Console.WriteLine(numberFmt, "Decimal.Zero", Decimal.Zero);
        Console.WriteLine();

        // Display the values of expressions of the Decimal fields.
        Console.WriteLine(exprFmt,
            "( Decimal.MinusOne ,Decimal.One ) == Decimal.Zero ",
            System.Convert.ToString(System.Decimal.Add(Decimal.MinusOne,
            Decimal.One) == Decimal.Zero));
        Console.WriteLine(exprFmt, "Decimal.MaxValue + Decimal.MinValue",
            System.Decimal.Add(Decimal.MaxValue, Decimal.MinValue));
        Console.WriteLine(exprFmt, "Decimal.MinValue / Decimal.MaxValue",
            System.Decimal.Divide(Decimal.MinValue, Decimal.MaxValue));
        Console.WriteLine("{0,-40}{1,30}","100000000000000M / Decimal.MaxValue",
            System.Decimal.Divide(System.Convert.ToDecimal(100000000000000L),
            Decimal.MaxValue));
    } //main
} //DecimalFieldsDemo

/*
This example of the fields of the Decimal structure
generates the following output.

Field or Expression                                              Value
-------------------                                              -----
Decimal.MaxValue                79,228,162,514,264,337,593,543,950,335
Decimal.MinValue               -79,228,162,514,264,337,593,543,950,335
Decimal.MinusOne                                                    -1
Decimal.One                                                          1
Decimal.Zero                                                         0

( Decimal.MinusOne + Decimal.One ) == Decimal.Zero                True
Decimal.MaxValue + Decimal.MinValue                                  0
Decimal.MinValue / Decimal.MaxValue                                 -1
100000000000000M / Decimal.MaxValue     0.0000000000000012621774483536
*/

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0
Show: