Meaningless Drivel is fun!*
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "binary representation & unicode value of char" Watch "binary representation & unicode value of char" New topic
Author

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:
f.ex.
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.
http://www.coderanch.com/t/238653/java-programmer-SCJP/certification/Converting-negative-numbers-binary
Veena


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

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

[ August 12, 2003: Message edited by: Alex Radomski ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: binary representation & unicode value of char