• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

binary representation & unicode value of char

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For first question I think following discussion will be helpfull.
https://coderanch.com/t/238653/java-programmer-SCJP/certification/Converting-negative-numbers-binary
Veena
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
This link might help: unicode webpage

[ August 12, 2003: Message edited by: Alex Radomski ]
 
There's a city wid manhunt for this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic