numbers - Need help to round up decimals Javascript -


im trying round 2 number , adding them after.

var = 12.24; var b = 12.27;

i want them round 12.5 when add these 2 numbers result 12.5 + 12.5 = 25

it's same shown in answer, using different multiplier/divisor. in question, wanted nearest 10th; in question, want nearest half. instead of

var num = 12.24; num = math.ceil(num * 10) / 10; alert(num); // 12.24 

...we use

var num = 12.24; num = math.ceil(num * 2) / 2; alert(num); // 12.5 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -