mathtools.least_power_of_two_greater_equal — Abjad v1.1.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »

# mathtools.least_power_of_two_greater_equal

`abjad.tools.mathtools.` `least_power_of_two_greater_equal`(n, i=0)

  Return least integer power of two greater than or equal to positive n.

      abjad> for n in range(10, 20):
      ...     print '\t%s\t%s' % (n, mathtools.least_power_of_two_greater_equal(n))
      ...
         10 16
         11 16
         12 16
         13 16
         14 16
         15 16
         16 16
         17 32
         18 32
         19 32

  When `i = 1`, return the first integer power of `2` greater than the least integer power of `2` greater than or equal to n.

      abjad> for n in range(10, 20):
      ...     print '\t%s\t%s' % (n, mathtools.least_power_of_two_greater_equal(n, i = 1))
      ...
         10 32
         11 32
         12 32
         13 32
         14 32
         15 32
         16 32
         17 64
         18 64
         19 64

  When `i = 2`, return the second integer power of `2` greater than the least integer power of `2` greater than or equal to n, and, in general, return the `i` th integer power of `2` greater than the least integer power of `2` greater than or equal to n.

  Raise `TypeError` on nonnumeric n:

      abjad> mathtools.least_power_of_two_greater_equal('foo')
      TypeError

  Raise `ValueError` on nonpositive n:

      abjad> mathtools.least_power_of_two_greater_equal(-1)
      ValueError

### Navigation

- index
- modules |
- next |
- previous |
- Project Abjad »
- Abjad v1.1.1 documentation »
- Abjad API »