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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exponent with variables

Status
Not open for further replies.

Bamarama

Programmer
Dec 29, 2006
49
US
I know the basic exponent formula using javascript:
(Math.pow(x,y)}

What I do not know, nor can I find is how to have x and y be variables.

x needs to be the variable of qty.value the formula I am using is

3000 * resfactor * 1.4(qty.value-1) the x-1 is the exponent.

so resfactor is a set variable of 40. so I could write this 120000(1.4 to the qty.value-1 power)

I hope I am making sense with this.

any help would be appreciated

 
I have tried this

value = (120000(Math.pow((1.4,(qty.value-1)))))

but It doesn't return anything. By anything I mean it returns blank field. I know the qty.value returns the value from the form, so that part is working.

anything look wrong here?
 
Ok, i think I answered my own question with this.

I used value = Math.floor(120000 * Math.pow(1.4,qty.value - 1));
and it appears to be working just fine.
 
while I am happy to have figured this out myself, I need help on one more thing. I need the number rounded down to the 10's only rounded down.

for example, if this forumla yields 1234566 i want it to display 1234560 how would I accomplish this?
 
Hi

Code:
Math[teal].[/teal][COLOR=darkgoldenrod]floor[/color][teal]([/teal][purple]1234566[/purple] [teal]/[/teal] [purple]10[/purple][teal])[/teal] [teal]*[/teal] [purple]10[/purple]

Feherke.
 
thanks for the reply

this helped me so I do appreciate it

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top