Browse Source

Math: Changed nearestPowerOfTwo to be smaller or equal. See #12208.

Mr.doob 8 năm trước cách đây
mục cha
commit
31e8e610b6
2 tập tin đã thay đổi với 2 bổ sung2 xóa
  1. 1 1
      docs/api/math/Math.html
  2. 1 1
      src/math/Math.js

+ 1 - 1
docs/api/math/Math.html

@@ -71,7 +71,7 @@
 		</div>
 
 		<h3>[method:Integer nearestPowerOfTwo]( [page:Number n] )</h3>
-		<div>	Returns the nearest power of 2 to a given number [page:Number n].</div>
+		<div>Returns the nearest power of 2 that is smaller or equal to [page:Number n].</div>
 
 		<h3>[method:Integer nextPowerOfTwo]( [page:Number n] )</h3>
 		<div>Returns the nearest power of 2 that is bigger than [page:Number n].</div>

+ 1 - 1
src/math/Math.js

@@ -144,7 +144,7 @@ var _Math = {
 
 	nearestPowerOfTwo: function ( value ) {
 
-		return Math.pow( 2, Math.round( Math.log( value ) / Math.LN2 ) );
+		return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );
 
 	},