Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Math Question 1

Status
Not open for further replies.

OldWilly

Programmer
Mar 1, 2002
66
I've forgotten my high school math. Am trying to write a formula in Cold Fusion to accomplish the following:

sales + tax = grand total

The numbers I have are the tax rate and the grand total.
In other words, if the grand total is 100 and the tax rate
is 10%, what was the sales price? (I know the answer is NOT
90 + 10 = 100). The sales price is closer to 93 or 94.

So how do I write it in a CF formula ?
<CFSET tax = ? * ?> etc. <CFSET sales = ??>
 
start with your equation, S + T = G

then recognize that T is an amount based on a rate, t * S

S + t * S = G

S * ( 1 + t ) = G

S = G / ( 1 + t )


helps?

rudy
 
yes and no. I can see the algebaic logic....
but how to put it in a CFSET command ?? .. I have no clue
 
<CFSET sales = grand / ( 1 + taxrate)>

<CFSET tax = sales * taxrate>
or
<CFSET tax = grand - sales>

the latter would resolve rounding discrepancies


rudy
 
works great - thank you
I don't suppose you would like to enlighten me on the significance of the numeral &quot;1&quot; ??
Whatever it is (and I guess what escaped me in the first place) does the job. Again thanks.
 
&quot;the significance of the numeral 1&quot;

oh, where to start?

in this particular case, 1 is the identity factor in multiplication

it is the answer to the question &quot;what number, whan multiplied by any other number, always yields that other number?&quot;

(in addition, the number 0 is the identity factor)

where did it come from?

by factoring it out of S + t*S = S*(1 + t)


thanks for the star

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top