FUNCTION
depreciation
Finance namespace
Interface
#include <codecogs/finance/accounting/depreciation.h>
using namespace Finance::Accounting;
This function calculates the depreciation of an asset for a specified period, using the double-declining balance method (or, more generally, any fixed-rate declining balance method controlled by fact). This function is equivalent to the Microsoft Excel function DDB. It works on the following equation, applied successively for each period up to and including per:
where:
and prevTot is the total depreciation accumulated over all previous periods (so the declining rate is always applied to the asset's remaining book value, cost - prevTot). The one exception is the final period before the asset reaches its salvage value: for that period, the depreciation is capped so that the asset's book value never drops below valSalv, i.e.:
Where:
- salv is the salvage value of the asset,
- cost is the initial cost of the asset,
- life is the number of periods over which the asset is being depreciated,
- fact is the declining-balance rate factor (2.0 for the standard "double" declining balance method),
- prevTot is the total depreciation from previous periods.
Example 1
The following code calculates the double-declining balance depreciation, for each of the first 10 years, of an asset costing 2400 with a salvage value of 300 and a useful life of 10 years (this is the worked example from Microsoft's own DDB documentation, used here to cross-check the two implementations).
#include <stdio.h>
#include <codecogs/finance/accounting/depreciation.h>
int main(void)
{
double costVal=2400;
double salvVal=300;
int lifeVal=10;
printf("Cost\tSalvage\tLife\tPeriod\tDepreciation\n");
for (int per=1; per<=lifeVal; ++per)
{
printf("%.0f\t%.0f\t%i\t%i\t%f\n",
costVal,
salvVal,
lifeVal,
per,
Finance::Accounting::depreciation(costVal, salvVal, lifeVal, per));
}
return 0;
}Output:
Cost Salvage Life Period Depreciation
2400 300 10 1 480.000000
2400 300 10 2 384.000000
2400 300 10 3 307.200000
2400 300 10 4 245.760000
2400 300 10 5 196.608000
2400 300 10 6 157.286400
2400 300 10 7 125.829120
2400 300 10 8 100.663296
2400 300 10 9 80.530637
2400 300 10 10 22.122547Parameters
Returns
References
Interactive Calculator
Computing…
Set a range above first to export a graph.