You can't halve a pixel. Truncating would get around the issue but big issue is that you can't have a float as a video resolution. The browser should just truncate it regardless but the original code is flawed.
OPs fix essentially does the same thing.