albertlee Posted February 12, 2005 Posted February 12, 2005 In Java, char is an unsigned data type Does any one know what does "unsigned" mean in that sense??? thx Albert
Dave Posted February 12, 2005 Posted February 12, 2005 It means that the number is always going to be positive. There's no bit to signify whether the number is positive or negative. A char is just a 1-byte data type (holds integers from 0-255), and the associated integers are matched up with the ASCII table.
albertlee Posted February 14, 2005 Author Posted February 14, 2005 Oh, so, do you mean that the left most bit of a byte is always 0 in char??? Albert
Cadmus Posted February 15, 2005 Posted February 15, 2005 A char is just a 1-byte data type (holds integers from 0-255), and the associated integers are matched up with the ASCII table. I think that you made a typo. In Java, the char data type is a 2 byte unsigned integer. The purpose of the 2 byte type was that Java was designed early on to support unicode.
Dave Posted February 15, 2005 Posted February 15, 2005 I missed the "in Java" bit, sorry. In most of the programming languages I know, a char is only 1 byte, but fair enough
albertlee Posted February 15, 2005 Author Posted February 15, 2005 Any one can refer to my previous message?? thx Albert
Cadmus Posted February 15, 2005 Posted February 15, 2005 Oh' date=' so, do you mean that the left most bit of a byte is always 0 in char???[/quote'] This is not correct. In a signed byte, there is one sign bit and 7 data bits. The maximum number of distinctions is 128 (2^7), which can be postive or negative, depending on the sign (range: -128 - +127). In the high order byte of the char type, there is no sign bit. Therefore, all 8 bits pertain to the value, the maximum number of distinctions of which is 256 (2^8), with the range 0 - 255.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now