File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes binary representation & unicode value of char Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "binary representation & unicode value of char" Watch "binary representation & unicode value of char" New topic

binary representation & unicode value of char

Shafkat Talli
Ranch Hand

Joined: Aug 01, 2003
Posts: 30
I have 2 questions:
Question 1:
i am trying to figure out how i get negative binary representation:
I have no problems with the positive numbers, but i dont understand how one gets negative numbers.
For example:
1100 0000 = 12
But what is = -12 , and how do one make a binary representation of it.

Question 2
One can get question on the exam where one needs to verify of valid declarations of char:
char a = '\u004E'
char b = '\ubeef'
char c = '\umonkey'
2 of these are right, and one wrong. But my question really is how i know if one unicode value is valid or not ? is there any reference to it on the net ?

All help appreciated.

---------------------------<br />Shafkat Talli<br />SCJP 1.4, August 2003.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Question #1: we use two's compliment. Reverse all the digits and add 1:
0000 1100

1111 0011 <-- reverse digits
0000 0001 <-- add 1
1111 0100 < -12
Question #2: Unicode is in hex so any 4 digit hex number is valid (there are a few exceptions to this because some of the unicode values are things like "new line" that cause the value to evaluate in your code into a new line which causes a syntax error).
[ August 12, 2003: Message edited by: Thomas Paul ]

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
For first question I think following discussion will be helpfull.

"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Alex Radomski

Joined: Apr 24, 2003
Posts: 24
This link might help: unicode webpage

[ August 12, 2003: Message edited by: Alex Radomski ]
I agree. Here's the link:
subject: binary representation & unicode value of char
It's not a secret anymore!