Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am confused with the size ans range of datatypes.I want to quote example for this:
In sbyte ,its size is 1 byte and range is -128 to 127.
and it is signed datatype. its size is 8 bits.
If I declare variable
C#
sbyte a;
                     a=-128;

Its binary form is 10000000
taking 8 bits but in signed datatype 1 bit is reserved for signed purpose (i.e 0 for positive number and 1 for negative number) here its 1
so binary form will be 110000000

Now, it wont satisfy the range and size which is defined by sbyte
as its size is 9 bits .
This is my interpretation
Please tell me am i right and if wrong,Please rectify me
Posted
Comments
BillWoodruff 18-Oct-11 0:56am    
After your recent comments, I realized that I was not clear on why and how an sByte could have a value of -128, so I have deleted my response. My apologies for any confusion !

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900