Legacy Documentation: Version 2018.2 (Go to current version)
LanguageEnglish
  • C#

Mathf.IsPowerOfTwo

public static bool IsPowerOfTwo(int value);

Description

Returns true if the value is power of two.

using UnityEngine;

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

// prints true Debug.Log(Mathf.IsPowerOfTwo(32)); } }

Did you find this page useful? Please give it a rating: