I am trying to allow my program to round a number up and down accordingly.
For example, if it is a number 3.6, my program should round the nearest number, which is 4, and if it is a number 3.4, it will be rounded to 3.
I tried to use the library ceilto get the average of 3 elements.
results = ceil((marks1 + marks2 + marks3)/3)
However, it ceilonly rounds the number down, but does not roll the number up.
There 1 algorithm came across
var roundedVal = Math.round(origVal*20)/20;
but I still can not determine the formula for some problem.
source
share