How can I make a program that answers a mathematical formula?

Asked

Viewed 58 times

1

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

Can you do that? If you can help me, thank you very much!

  • 2

    My friend I didn’t understand was nothing of the question! But wouldn’t it be something like that? (1500/360).toFixed(0) - 1500;. In other words: (x/y).toFixed(0) - y;

1 answer

7

I don’t know which formula interests 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 well noted by @Sergio, it may be more appropriate to use Math.floor in place of Math.round, if you prefer to truncate instead of round.

See working on CODEPEN.


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.