diff --git a/lib/codemirror.js b/lib/codemirror.js
index <HASH>..<HASH> 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -823,7 +823,7 @@ var CodeMirror = (function() {
     }
 
     function updateVerticalScroll(scrollTop) {
-      var th = textHeight(), virtualHeight = doc.height * th + 2 * paddingTop(), scrollbarHeight = scroller.clientHeight;
+      var th = textHeight(), virtualHeight = Math.floor(doc.height * th + 2 * paddingTop()), scrollbarHeight = scroller.clientHeight;
       scrollbar.style.height = scrollbarHeight + "px";
       if (scroller.clientHeight)
         scrollbarInner.style.height = virtualHeight + "px";
@@ -1093,7 +1093,7 @@ var CodeMirror = (function() {
         // after the scrollbar appears (during updateVerticalScroll()). Only do this if the scrollbar is
         // appearing (if it's disappearing, we don't have to worry about the scroll position, and there are
         // issues on IE7 if we turn it off too early).
-        var virtualHeight = doc.height * th + 2 * paddingTop(), scrollbarHeight = scroller.clientHeight;
+        var virtualHeight = Math.floor(doc.height * th + 2 * paddingTop()), scrollbarHeight = scroller.clientHeight;
         if (virtualHeight > scrollbarHeight) scrollbar.style.display = "block";
         checkHeights();
       } else {
Round off fractional pixel in virtual scroll height calculation