Q.What are the minimum and maximum income values that can be entered in the income attribute given the data type is INT?
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →INT in MySQL is a 4-byte signed integer, so the income attribute can hold values from −2 147 483 648 to 2 147 483 647 (that is, −2³¹ to 2³¹ − 1, roughly ±214 crore). Anything outside that range raises an Out of range error. Because income is never negative, declaring the column INT UNSIGNED (0 to 4 294 967 295) is the better design.
Where the numbers come from
INT uses 4 bytes = 32 bits. In a signed type one bit encodes the sign, leaving 31 bits for the magnitude:
| Value | |
|---|---|
| Minimum | −2³¹ = −2 147 483 648 |
| Maximum | 2³¹ − 1 = 2 147 483 647 |
| Total distinct values | 2³² = 4 294 967 296 |
The maximum is one less than 2³¹ because one of the 2³² bit-patterns is used for zero.
print("INT signed min :", -2 ** 31)
print("INT signed max :", 2 ** 31 - 1)
print("INT unsigned min :", 0)
print("INT unsigned max :", 2 ** 32 - 1)
Output
INT signed min : -2147483648
INT signed max : 2147483647
INT unsigned min : 0
INT unsigned max : 4294967295
Seeing it in MySQL
CREATE TABLE EMPLOYEE (
EmpID INT PRIMARY KEY,
income INT -- 4-byte SIGNED integer
);
INSERT INTO EMPLOYEE VALUES (1, 2147483647); -- the maximum: accepted
INSERT INTO EMPLOYEE VALUES (2, -2147483648); -- the minimum: accepted
INSERT INTO EMPLOYEE VALUES (3, 2147483648); -- one MORE than the maximum
Output
Query OK, 1 row affected (0.01 sec)
Query OK, 1 row affected (0.00 sec)
ERROR 1264 (22003): Out of range value for column 'income' at row 1
The third statement fails: 2 147 483 648 simply cannot be represented in 32 signed bits.
SELECT * FROM EMPLOYEE;
| EmpID | income |
|---|---|
| 1 | 2147483647 |
| 2 | -2147483648 |
| 3 (rejected) | — |
In MySQL's non-strict mode the out-of-range value is not rejected but silently clamped to 2147483647 with a warning. Silent data corruption is far worse than an error — this is one reason strict mode is the default in modern MySQL.
Is INT the right choice for income?
| Declaration | Range | Comment |
|---|---|---|
INT | −2 147 483 648 … 2 147 483 647 | half the range (all the negatives) is wasted — an income cannot be negative |
INT UNSIGNED | 0 … 4 294 967 295 | better: doubles the usable maximum and makes a negative income impossible |
BIGINT | ±9.22 × 10¹⁸ | for very large amounts |
DECIMAL(12, 2) | exact, up to 10 digits + 2 decimals | best for money — allows paise and never rounds |
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.