Ask Question

Why do primitive types have ranges of values? what determines the range of the data type?

+5
Answers (1)
  1. 28 July, 19:38
    0
    What determines the range of primitive data types is a combination of the number of bytes that is allocated to them and if there's any encoding.

    Not too long ago, it was normal for an integer to receive four bytes of memory. An unsigned integer would also receive four bytes of memory. The unsigned int had a range of 0 - (2^32 - 1) because it could only be used for positive integers and could use all 32 bits. An integer has a range of ( - 2^31 through + 2^31 - 1). The 32nd bit is uses as a sign bit (0 for positive, 1 for negative).

    Just for thoroughness: when an int is negative, it's stored as the two's complement of it's absolute value.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Why do primitive types have ranges of values? what determines the range of the data type? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers