On Apr 23, 3:26 am, wutzke <michael.wut...@gmail.comwrote:

I started working on a script that would take the cost of something

and suggest a retail amount.

I usually figure Retail on Margins. So Retail equals Cost divided by

(Margin-100)% plus Cost.

So if Cost is $50 and Margin is 40%

50/(40-100)%+50=80

or

(50/60%)+50=80

Either your equation is defective or I don't understand it. If your

retail price is cost plus margin, where margin is expressed as a

percentage of the cost, then for a 60% margin:

var margin = 60;

var rrp = cost * (1 + margin/100);

If margin is expressed as a decimal number (i.e. 0.6 rather than 60)

the formula becomes:

var margin = 0.6;

var rrp = cost * (1 + margin);

For rounding to a set number of decimal place, see the FAQ:

<URL

http://www.jibbering.com/faq/ >

--

Rob