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; }
1.4m articles
1.4m replys
5 comments
57.0k users