Monday, April 22, 2019

math - Integer division with remainder in JavaScript?



In JavaScript, how do I get:




  1. the whole number of times a given integer goes into another?

  2. the remainder?


Answer




For some number y and some divisor x compute the quotient (quotient) and remainder (remainder) as:



var quotient = Math.floor(y/x);
var remainder = y % x;

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...