Jump to content


Photo
- - - - -

Sum of the Years' Digits Method of Depreciation


2 replies to this topic

#1 Matthews Estrice

Matthews Estrice

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 241 posts
  • Gender:Male
  • Location:Henley-on-klip

Posted 10 September 2012 - 08:39 AM

Dear All,

I am having a problem in rounding the year faction,I get wrong results.Please refer to the comments and the UMSGs on the logic below.

This happens when the infinite decimals are greater than .55 the fraction rounds to 2 decimal places.I tried forcing the logic to round to 8 decimal places using the ROUND method,no luck.

Below is my logic:-

//Sum of the Years' Digits Method of Depreciation
//=====================================
#EndOfTheYear = 5
#PurchasePrice = 65000
#SalvageValue = 5000
#SYD = (#EndOfTheYear * (#EndOfTheYear + 1)) / 2
#ProCountNumber = #EndOfTheYear - #ProCountNumber
#DepreciableCost = #PurchasePrice - #SalvageValue
UMSG("#SYD = " + CONV(#SYD),-1)
UMSG("#DepreciableCost = " + CONV(#DepreciableCost),-1)
//annual depreciation Calculation
//-------------------------------
#annual_depreciation = (#ProCountNumber / #SYD) * #DepreciableCost
UMSG("#annual_depreciation = " + CONV(#annual_depreciation),-1)
//Increase End of the year by ONE
#ProCountNumber += 1
//Accumulated depreciation Calculation
//------------------------------------
#fractional = 0.5
#YearsFractionA = ROUND((#ProCountNumber / #SYD) * #fractional,8)
UMSG("#YearsFractionA | 0.2 IS WRONG = " + CONV(#YearsFractionA),-1)
//#YearsFractionA suppose to be equal to 0.1666666666666667 but I get 0.2 because
//of the infinit rounding of a number greater than 5 to 2 decimal places.
//The display mask and the external data type on the FD variable is 1.8
#YearsDepreciationA = #DepreciableCost * #YearsFractionA
//#YearsDepreciationA (First Years' depreciation and First Years' Accumulated depreciation)
//was suppose to be equal to 10000 but I get 12000
UMSG("#YearsDepreciationA | IS ALSO WRONG = " + CONV(#YearsDepreciationA),-1)
//ToDo for the Remaining useful life
//Reducing the #EndOfTheYear(Remaining useful life) by ONE
#EndOfTheYear = #EndOfTheYear - #ProCountNumber
FNEXIT


Thank you in advance,

Matthews Estrice

#2 Chris Mackenzie

Chris Mackenzie

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 368 posts
  • Gender:Male
  • Location:Bristol, United Kingdom

Posted 10 September 2012 - 10:30 AM

Dear All,

I am having a problem in rounding the year faction,I get wrong results.Please refer to the comments and the UMSGs on the logic below.

This happens when the infinite decimals are greater than .55 the fraction rounds to 2 decimal places.I tried forcing the logic to round to 8 decimal places using the ROUND method,no luck.

Below is my logic:-

//Sum of the Years' Digits Method of Depreciation
//=====================================
#EndOfTheYear = 5
#PurchasePrice = 65000
#SalvageValue = 5000
#SYD = (#EndOfTheYear * (#EndOfTheYear + 1)) / 2
#ProCountNumber = #EndOfTheYear - #ProCountNumber
#DepreciableCost = #PurchasePrice - #SalvageValue
UMSG("#SYD = " + CONV(#SYD),-1)
UMSG("#DepreciableCost = " + CONV(#DepreciableCost),-1)
//annual depreciation Calculation
//-------------------------------
#annual_depreciation = (#ProCountNumber / #SYD) * #DepreciableCost
UMSG("#annual_depreciation = " + CONV(#annual_depreciation),-1)
//Increase End of the year by ONE
#ProCountNumber += 1
//Accumulated depreciation Calculation
//------------------------------------
#fractional = 0.5
#YearsFractionA = ROUND((#ProCountNumber / #SYD) * #fractional,8)
UMSG("#YearsFractionA | 0.2 IS WRONG = " + CONV(#YearsFractionA),-1)
//#YearsFractionA suppose to be equal to 0.1666666666666667 but I get 0.2 because
//of the infinit rounding of a number greater than 5 to 2 decimal places.
//The display mask and the external data type on the FD variable is 1.8
#YearsDepreciationA = #DepreciableCost * #YearsFractionA
//#YearsDepreciationA (First Years' depreciation and First Years' Accumulated depreciation)
//was suppose to be equal to 10000 but I get 12000
UMSG("#YearsDepreciationA | IS ALSO WRONG = " + CONV(#YearsDepreciationA),-1)
//ToDo for the Remaining useful life
//Reducing the #EndOfTheYear(Remaining useful life) by ONE
#EndOfTheYear = #EndOfTheYear - #ProCountNumber
FNEXIT


Thank you in advance,

Matthews Estrice


Are you sure you have this example quite correct?

SYD=5*6/2=15
ProCountNumber = 5 + 1=6

6/15*0.5=0.2

I've not finished my morning coffee yet so maybe I have a blind spot
The content and views expressed in this message are those
of the poster and do not represent those of any organisation.

#3 Matthews Estrice

Matthews Estrice

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 241 posts
  • Gender:Male
  • Location:Henley-on-klip

Posted 10 September 2012 - 12:02 PM

Hi Chris,
I commented out the line where I incremented #ProCountNumber by 1 which is line 16 on my logic
I now get .25 cents more than what I expected.They can
pass a journal for that amount :-)

This is what happens when coding during mid-night,I was tired to spot this one.

Thank you Chris.
Matthews



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users