tiscavalcanti Posted June 26, 2015 Share Posted June 26, 2015 (edited) I need make a calculation which allow know difference between two numbers. I can subtract the smallest of the larger, but this calculation is very limited, implies if a number is negative and the other positive. I want to know another way to do this. It is possible to do this calculation in JavaScript through the: modulo; function; (Others); Mainly: Another important thing which I want, is to calculate percentage difference through two differents numbers. To know the value resultant. I want to know all the possible ways to do this. Because I came across in an embarrassing situation in a video Software that uses expressions based on the JavaScript language. Thanks! Edited June 26, 2015 by tiscavalcanti Link to comment Share on other sites More sharing options...
justsomeguy Posted June 26, 2015 Share Posted June 26, 2015 If you're trying to calculate the "distance" between two numbers as a positive value, that's the absolute value. The Math object has a method for it.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math Another important thing which I want, is to calculate percentage difference through two differents numbers. To know the value resultant.To get the percentage difference you would take the absolute value of the difference and then divide the original number by that. 1 Link to comment Share on other sites More sharing options...
tiscavalcanti Posted June 26, 2015 Author Share Posted June 26, 2015 (edited) Thank you! Edited June 26, 2015 by tiscavalcanti Link to comment Share on other sites More sharing options...
tiscavalcanti Posted June 26, 2015 Author Share Posted June 26, 2015 If you're trying to calculate the "distance" between two numbers as a positive value, that's the absolute value. The Math object has a method for it.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/MathTo get the percentage difference you would take the absolute value of the difference and then divide the original number by that. You can take some examples, please? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 26, 2015 Share Posted June 26, 2015 That MDN site has examples for all of the methods in the Math object. The other one is just some subtraction and division. Get started and ask questions if you get stuck. Link to comment Share on other sites More sharing options...
tiscavalcanti Posted June 26, 2015 Author Share Posted June 26, 2015 That MDN site has examples for all of the methods in the Math object. The other one is just some subtraction and division. Get started and ask questions if you get stuck. Okay. Link to comment Share on other sites More sharing options...
tiscavalcanti Posted June 29, 2015 Author Share Posted June 29, 2015 (edited) That MDN site has examples for all of the methods in the Math object. The other one is just some subtraction and division. Get started and ask questions if you get stuck. I got. Examples: .20*76 | 20% of 76 = 15.2 1.20*76 | 76 + 20% = 91.2 (1-.20)*76 | 76 - 20% = 60.8 Calculate numerical difference between two values: (-8)+(3) = - 5 | balance value. (-8)-(3) = 11 | difference value. This is it. Thanks. Edited June 29, 2015 by tiscavalcanti Link to comment Share on other sites More sharing options...
justsomeguy Posted June 29, 2015 Share Posted June 29, 2015 I don't really understand what you're saying, but you can use the +, -, *, and / operators to do basic math. Link to comment Share on other sites More sharing options...
tiscavalcanti Posted June 29, 2015 Author Share Posted June 29, 2015 I don't really understand what you're saying, but you can use the +, -, *, and / operators to do basic math. Good, you is right, Thank You! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now