QuickBreakdown 1948 Posted August 28, 2015 Report Share Posted August 28, 2015 Some useful formula I came across while studying. You can calculate the maximum value for pretty much any data type in most cases.Though this appears to be pretty basic stuff, I thought i'd share it with you. Formula : 2^(n-1)-1 (signed) 2^(n-1) (unsigned) N = Amount of bits^ = Power For example in Java an integer is 4 bytes which is 32 bits. (1 byte = 8 bits). 2^(32-1)-1 = 2147483647 as maximum value for an integer (signed) or -2147483648 (unsigned) Azeri, Puddingsbane and JJBKILLER like this Quote Link to post Share on other sites
Azeri 139 Posted August 28, 2015 Report Share Posted August 28, 2015 I learned this formula for my school leaving exams :p And a lot other at arithmetics, but I don't use it anymore, because business IT D: But it is useful! Quote Click image for steam profile http://i.imgur.com/JHif3CC.gif Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.