Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


IsPowerOfTwo(int)

Returns true if the value is power of two.
Read time 1 minuteLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public static bool IsPowerOfTwo(int value)

Parameters

value

Returns

Type

Description

bool

Examples

using UnityEngine;public class Example : MonoBehaviour{ void Start() { // prints false Debug.Log(Mathf.IsPowerOfTwo(7)); // prints true Debug.Log(Mathf.IsPowerOfTwo(32)); }}