can sum1 explain exactly how this program calculates the number of bits required to store a number(i got it off a tutorial and its aint explainin)

thankz in advanceCode:#include <iostream> using namespace std; int main() { int bitsRequired = 1; int largest = 1; int powerOf2 = 2; int number; cout << "Enter a positive integer: "; cin >> number; while (number > largest) { bitsRequired += 1; powerOf2 = powerOf2 * 2; largest = powerOf2 - 1; } cout << "To store " << number << " requires "; cout << bitsRequired << " bits" << endl; cin.ignore(); cin.get(); return 0; }