bit_manipulation.next_power_of_two ================================== .. py:module:: bit_manipulation.next_power_of_two .. autoapi-nested-parse:: Author : Basuki Nath Date : 2025-10-04 Utility to compute the next power of two greater than or equal to n. Functions --------- .. autoapisummary:: bit_manipulation.next_power_of_two.next_power_of_two Module Contents --------------- .. py:function:: next_power_of_two(n: int) -> int Return the smallest power of two >= n for positive integers. >>> next_power_of_two(1) 1 >>> next_power_of_two(2) 2 >>> next_power_of_two(3) 4 >>> next_power_of_two(5) 8 >>> next_power_of_two(1025) 2048 >>> next_power_of_two(0) Traceback (most recent call last): ... ValueError: n must be positive >>> next_power_of_two(-3) Traceback (most recent call last): ... ValueError: n must be positive