Sebastian Patten Sebastian Patten - 1 year ago 83
Javascript Question

How do I get the quotient as int and remainder as a floating point in JavaScript

On my calculator when I do 18/7 I get 2.5714285714285714285714285714286.
From my super limited Math skills 2 is the quotient and .5714285714285714285714285714286 is the remainder.

How can I model this in JavaScript?


Answer Source
var floatingPointPart = (18/7) % 1;
var integerPart = Math.floor(18/7);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download