Power of Two Checker

Full53bitBigIntpoweroftwoincluding zero=false,not nextpowerdistance. Explicitboundedofflineconvention,not authoritative external identity,eligibility,clinical or safe-use determination.

Description

A positive power of two has exactly one set bit in its binary integer representation.

A positive power of two has exactly one set bit in its binary integer representation.1

This checker supports the full nonnegative JavaScript safe-integer range instead of truncating values to 32 bits.

When to use Power of Two Checker

Use this tool to apply the stated power of two checker operation with an explicit input and unit basis.

How to use Power of Two Checker and how it works

  1. Establish the text or game convention described above.
  2. Enter actualNonnegativeSafeInteger and run the tool.
  3. Read result.isPowerOfTwo using the output meanings below.
  4. If input is rejected, correct the stated type, range, ordering or alignment issue and rerun; review successful results under the declared convention.
Input fieldMeaningValue typeRequirement
actualNonnegativeSafeIntegerNonnegative integer no greater than Number.MAX_SAFE_INTEGER (2^53−1).numberrequired; finite; further conditions in the algorithm

Require a nonnegative safe integer, convert it exactly to BigInt and count set bits by repeatedly clearing the lowest set bit. Return true only when the count is one; zero returns false.

isPowerOfTwo = popcount(n) === 1

Apply the declared units, ordering and branch conditions.

Output fieldMeaningValue type
resultObject containing the declared output fields.object
result.isPowerOfTwoTrue when the integer has exactly one set bit; zero is false.boolean
json
{
  "input": {
    "actualNonnegativeSafeInteger": 1099511627777
  },
  "output": {
    "result": {
      "isPowerOfTwo": false
    }
  }
}

Limitations and assumptions

The output applies the declared operation to the values you supply. Establish the measurement basis, units, coefficients and any caller-selected rules before interpreting it. The tool does not independently collect or verify observations or decide whether a model or reference applies.

Supply explicit required fields with the documented types and dense aligned arrays. Unknown fields, wrong types and nonfinite numbers are rejected. Branch-specific constraints are explained above. A returned boolean, signed difference or tied result follows the stated convention; an input error instead means the required input contract was not satisfied. Very large inputs or outputs may be rejected by shared resource limits.

Alternative or Complementary methods

For a related operation, use Population Count Calculator. Population count is the number of one bits in an integer’s binary representation.

For a related operation, use Scientific Notation Formatter. Scientific notation expresses a value as a coefficient followed by a power of ten.

References

  1. Power of Two Checker — tool.io

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies