Can someone give me an idea how can i round off a number to the nearest 0.5. I have to scale elements in a web page according to screen resolution and for that i can only assign font size in pts to 1, 1.5 or 2 and onwards etc.
If i round off it rounds either to 1 decimal place or none. How can i accomplish this job?
Write your own function that multiplies by 2, rounds, then divides by 2, e.g.
function roundHalf(num) { return Math.round(num*2)/2; }
2.1m questions
2.1m answers
60 comments
57.0k users