This documentation is archived and is not being maintained.

# Decimal.Subtract Method

.NET Framework 1.1

Subtracts one specified Decimal value from another.

```[Visual Basic]
Public Shared Function Subtract( _
ByVal d1 As Decimal, _
ByVal d2 As Decimal _
) As Decimal
[C#]
public static decimal Subtract(
decimal d1,
decimal d2
);
[C++]
public: static Decimal Subtract(
Decimal d1,
Decimal d2
);
[JScript]
public static function Subtract(
d1 : Decimal,
d2 : Decimal
) : Decimal;```

#### Parameters

d1
A Decimal (the minuend).
d2
A Decimal (the subtrahend).

#### Return Value

The Decimal result of subtracting d2 from d1.

#### Exceptions

Exception Type Condition
OverflowException The return value is less than MinValue or greater than MaxValue.

#### Example

The following code sample illustrates the use of Subtract:

```[Visual Basic]
Class PiggyBank
Public ReadOnly Property Cents() As Decimal
Get
Return [Decimal].Subtract(MyFortune, [Decimal].Floor(MyFortune))
End Get
End Property

Protected MyFortune As Decimal

MyFortune += 0.01D
End Sub
End Class

[C#]
class PiggyBank {
public decimal Cents {
get {
return Decimal.Subtract(MyFortune, Decimal.Floor(MyFortune));
}
}

protected decimal MyFortune;

public void AddPenny() {
MyFortune += .01m;
}
}

[C++]
public __gc class PiggyBank {
public:
Decimal Cents() {
return Decimal::Subtract(MyFortune, Decimal::Floor(MyFortune));
}

}
protected:
Decimal MyFortune;
};

[JScript]
class PiggyBank {
public function get Cents() : Decimal {
return Decimal.Subtract(MyFortune, Decimal.Floor(MyFortune));
}

protected var MyFortune : Decimal;

public function AddPenny() {
MyFortune = Decimal.Add(MyFortune, 0.01);
}
}
```

#### Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard