|
#1
|
|||
|
|||
|
Making Var Stay Put!
Greetings those who know javascript(otherwise disregard). I'm having a bit of trouble with controlling my variables. I don't know of a simple example so I'll just flat out tell you what I'm doing. I'm trying to make a system of equations solving program using the elimination method.
Lets say you have (X1+Y1+Z1=C1) (X2+Y2+Z2=C2) now in substitution you multiply each factor by one factor in the opposite equation, such as.. X2(X1+Y1+Z1=C1) (-1*X1)(X2+Y2+Z2=C2) in this step i can say var X1=5; var X2=10; X1*=X2; //X1 now is now 50; //now we do the second part X2=X1*-1 //when we say X1 we were hoping for 5 but no luck since it's 50. you see what i mean? I could create a separate variable to hold the value of X1 then use that to multiply by -1 to get X2 but I'm doing a system with 3 unknowns with numerators and denominators. Having to make a new variable for every time I want to change the X1 term, and structure wise, that just won't cut it. Any other ways around this? Last edited by jan00b; October 17th, 2007 at 07:50 AM. |
|
#2
|
||||
|
||||
|
There's no other way around it. What you need will require multiple variables. But feel free to use arrays where more efficient. My only suggestion is, for easier comprehension, never change the values of your base variables (X1, X2 etc), in fact make them constants where possible.
__________________
Oracle's backup tutorial "A lot of people say games are addictive. Well, they're addictive in the sense that anything you like doing you repeat endlessly. But no one would say, 'Mr Kasparov, you have a chess problem,' or 'Tiger Woods, you have a golf addiction.'" - Ian Livingstone, Creative Director, Eidos. "A problem well stated is a problem half solved" - Charles Franklin Kettering |
![]() |
| Bookmarks |
«
Previous Topic
|
Next Topic
»
| Topic Tools | |
|
|
All times are GMT +1. The time now is 02:49 AM.
[
RSS ]








