How can I make a program that answers a mathematical formula? [closed]

1

I would like to put this formula in javascript: ("") / 360="" will give a comma number and I want only the first number before the comma "" x360="" now it will get the result that gave the multiplication and will do - the initial value ("

Can you do this? if you can help me, thank you very much!

    
asked by anonymous 02.04.2017 / 06:12

1 answer

7

I do not know which formulas interest you, but see if anything helps:

 var numero = 1230;

 // se quiser numero/360 = resultado
 var resultado1 = Math.round( numero / 360 ); 

 // se quiser resultado/360 = numero
 var resultado2 = Math.round( numero * 360 );

 // ou se quiser o resto da divisão inteira:
 var resultado3 = numero % 360;

As noted by @Sergio, it may be more appropriate to use Math.floor instead of Math.round if you prefer to truncate instead of round.

See working at CODEPEN .


If it is not, click "edit" below your question and explain in more detail, preferably examples, and leave a message here in the answer for me to update (but before the message, update the question). >     

02.04.2017 / 06:29