Mathf.ClosestPowerOfTwo 最近的二次方

static function ClosestPowerOfTwo (value : int) : int

Description描述

Returns the closest power of two value.

返回距离value最近的2的次方数。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
		Debug.Log(Mathf.ClosestPowerOfTwo(7));
		Debug.Log(Mathf.ClosestPowerOfTwo(19));
	}
}
// prints 8
Debug.Log(Mathf.ClosestPowerOfTwo(7));

// prints 16
Debug.Log(Mathf.ClosestPowerOfTwo(19));
Page last updated: 2011-2-23