Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 26 OCT 2006 08:42:30AM Barry Stevens wrote:

I need a formula\algorith in rbasic to (I hope i explain this properly) calculate the value of a percentage that has bee added to a figure. i.e.

I know the %rate (e.g. 2%) and I know the value after the % has been added (e.g. 660.96), I need to know the value that was added (e.g. 12.96). The %rate can vary.

-Barry


At 26 OCT 2006 09:44AM dbakke@srpcs.com's Don Bakke wrote:

Barry,

 
Rate           =.02 
NewValue       =660.96 
ValueIncrease  =12.96 
BaseValue      =NewValue / (1 [/color]+ Rate) ; [/color]// i.e. 660.96 / 1.02=648.00[/color][/color][/size]         
               

dbakke@srpcs.com

SRP Computer Solutions, Inc.


At 26 OCT 2006 01:04PM Karen Oland wrote:

Expanding on Don's answer (which gave you the calculation for the base amount), the amount added is

ValueIncrease=if Rate=1 then NewValue else (NewValue - (NewValue / (1 + Rate)))

The first part might be unnecessary, but will protect against a divide by zero error ever occuring.


At 26 OCT 2006 01:11PM Warren Auyong wrote:

rate would have to be -1 for divide by zero to occur


At 26 OCT 2006 01:23PM Karen Oland wrote:

Sorry, it must have dropped out of my post …. but, you get the idea.

If you are absolutely sure that no such value can occur, you don't need error checking …. but with my customers (and the app has lots of margin calcs), no such assurance exists (not just for numbers, although the app does try to anticipate all the rather interesting choices they try to make … such as paying negative hours at a negative rate in payroll).


At 26 OCT 2006 06:31PM Barry Stevens wrote:

Thank you very very much Don and Karen

-Barry

View this thread on the Works forum...

  • third_party_content/community/commentary/forums_works/ee518a40fe6f813f852572130045cf70.txt
  • Last modified: 2024/01/04 20:57
  • by 127.0.0.1