what is the largest value you can present using a 256-bit signed integer?
positive value: 2147483647 and for negative value: - 2147483648 Formula to calculate these kind of values: Postive value: (2 ^ (n -1)) -1 Negative value: - 2 ^ (n-1) for more you may visit http://en.wikipedia.org/wiki/Integer_%28computer_science%29
that's not what i want......but anyway u hjad tried @xaadi1993
emm then i think as bit contains two posiblities so 0 or 1 ; so we can say largest value can be stored will be (2^256)-1 it may work :P
@msamido
this one (2^256)-1 is correct for signed........but im not sure for unsigned.@xaadi1993
hmmmmm :/
1 bit is for sign, other 255 bits are for number: it's a huge number, more or less 5,789604462×10⁷⁶
The precise limits depend on how the computer and/or programming language represent negative integers; see http://stackoverflow.com/questions/704908/compilers-and-negative-numbers-representations http://en.wikipedia.org/wiki/signed%20number%20representations and http://en.wikipedia.org/wiki/Two%27s%20complement Suppose that you are using the C++ language on a computer that uses two's complement to represent negative numbers. In order to most easily understand this, you might want to consider what happens if you only have a single byte to work with. First, consider the largest possible UNSIGNED number. If you have only 8 bits to work with, the largest possible UNSIGNED number is binary 11111111 (hex FF, dec. 255), which is equal to (2^8)-1 or, to generalize to any arbitrary number of bits, (2^n)-1. But when you're using two's complement to represent a SIGNED number using 8 bits, then binary numbers 10000000 (hex 80, dec. 128) through 11111111 (hex FF, dec. 255) all represent negative numbers (with binary 11111111 representing a value of -1). Therefore, the largest SIGNED 8-bit integer is 127, which is also equal to (2^7)-1 or, to generalize to any arbitrary number of bits, (2^(n-1))-1. (The fact that binary 10000000 in a signed 8-bit binary system represents -128 and not 128 is by convention only; all other numbers represent a unique value). Using these principles, you can verify the formulas in the table http://en.wikipedia.org/wiki/Integer%20%28computer%20science%29#Common_integral_data_types and calculate the ranges of integers that can be represented, assuming a two's complement representation, using any arbitrary number of bits.
Join our real-time social learning platform and learn together with your friends!