I have to divide n
number into 3 parts according to given rule but the divided number should not be a floating-point number if the given n
is an odd number.
Example
`const rule = [50,30,20]` . // in percentagee
const n = 10;
the expected result should // 5,3,2
but if the given number is an odd number then the output should be as given below
n = 9
output 4,3,2
when getting the percentage according to rules it comes as follow
4.5,2.7,1.8
Now I want if the fractional part of the number is up to .5, the argument should be rounded to the next lower integer. If the fractional part of the number is greater than .5, the argument is rounded to the next higher integer.
This is NOT asking how to round floating point numbers, as the dupe target says. This is asking how to round DOWN .5 cases.
ANSWER: var result = -Math.round(-num);