File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Converting probability Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Converting probability" Watch "Converting probability" New topic
Author

Converting probability

Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

What percentage of questions are based on converting numbers from hex to decimal and the like?
And do they tend to be complex like 0xFFFFFFF?

15 x 16^6 + 15 x 16^5 + 15 x 16^4 + 15 x 16^3 + 15 x 16^2 + 15 x 16^1 + 15 x 16^0 = ?

This would be very time consuming.

??


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

Live life to an interface, not an implementation!
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
It's -1, it took me 10ms or less. Any bit flippers you get will be simple. Stop worrying, go through a few more mock exams - like Marcus Green's. I lost my 4% in SCJP when solving the loops questions - they are difficult especially when you have three people trying to fix a defective computer next to you when you are trying to do the exam.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

How on earth did you acheive that result in 10ms? Obviously you either used a calculator or you have seen this number before..

Although, thanks for your reply, it has actually calmed me down a little.
Sergei Iakhnin
Ranch Hand

Joined: Nov 09, 2004
Posts: 53
That can't be -1. It's a positive number that's equal to

0000 1111 1111 1111 1111 1111 1111 1111 (binary)


I'm fairly certain they will never ask you to convert such a number to decimal. But they might to binary, which is much easier. As far as I know pretty much all questions on this topic are easy and if they look hard to you then you're missing a trick that will make it easy.
[ August 15, 2005: Message edited by: Sergei Iakhnin ]

SCJP 1.4, SCWCD 1.4
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

Sergei, what trick?
Sergei Iakhnin
Ranch Hand

Joined: Nov 09, 2004
Posts: 53
Originally posted by Marzo Kaahn:
Sergei, what trick?


There is no one trick that will let you solve all the questions easily you just need to be observative about what they are asking you to do in a particular question. But if you are doing a question where you find yourself having to multiply 431531 by 85923523 in with only the pen and piece of paper that they give you then you are obviously missing something key.

The will do things like shifting integers by 33 for instance. There you know that you only need to shift by 1 as a result. Or they will downcast the result to a byte so you know that you only need to look at the 8 lowest bits which will be some small number.

You will need to remember two's complement well and be able to convert any base to binary well. With that mastered you shouldn't encounter any problems.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Barry Gaunt:
...especially when you have three people trying to fix a defective computer next to you when you are trying to do the exam.

Don't get me started on Prometric.
[ August 15, 2005: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Philip Heller
author
Ranch Hand

Joined: Oct 24, 2000
Posts: 119
The SCJP exam tests your knowledge of Java, not your ability to convert hex or binary to decimal. As long as you understand 2's complement, you'll be fine.

-- Phil


Consultant to SCJP team.<br />Co-designer of SCJD exam.<br />Co-author of "Complete Java 2 Certification Study Guide".<br />Author of "Ground-Up Java".
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Originally posted by Sergei Iakhnin:
That can't be -1. It's a positive number that's equal to

0000 1111 1111 1111 1111 1111 1111 1111 (binary)




Well, um, ah, ouch, yes. Moral: When you are at a party, never slip away for five minutes to checkout SCJP. Just have another drink and relax.
Sergei Iakhnin
Ranch Hand

Joined: Nov 09, 2004
Posts: 53
Originally posted by Barry Gaunt:



Well, um, ah, ouch, yes. Moral: When you are at a party, never slip away for five minutes to checkout SCJP. Just have another drink and relax.


Dionysus' revenge is swift for those who betray him thus.
Smitha Ballikar
Ranch Hand

Joined: Aug 02, 2005
Posts: 99
Hi All,

Regarding bits, I know how to work with bitwise operators like &,| or ^.
Also know about ~.I know that binary to octal and hexadecimal conversion.
Now, where do we need 2s complement here? I just know its negating the bits and adding 1.Do I need to read more about 2s complement for the exam and where do i use it?
In most of the forums thay have indicated you need to know 2s complement well?I am confused as to where it is to used?

Cheers
Sergei Iakhnin
Ranch Hand

Joined: Nov 09, 2004
Posts: 53
You just need to know 2's complement to be able to negate binary numbers so that when you need to evaluate 1111 1111 1111 1111 1111 1111 1111 1011 you don't start pulling hair but instead know that it's -5
Smitha Ballikar
Ranch Hand

Joined: Aug 02, 2005
Posts: 99

You just need to know 2's complement to be able to negate binary numbers so that when you need to evaluate 1111 1111 1111 1111 1111 1111 1111 1011 you don't start pulling hair but instead know that it's -5

Hi Sergei,

Thanks for your reply...
But now I didnt get how it is -5.Could you please explain this in detail.I think I am missing something about 2s complement.

Cheers!!
Sakti Singh
Greenhorn

Joined: Dec 13, 2000
Posts: 16
Smitha,

Binary negative numbers are expressed in 2's complement. To get 2's complement of binary number b you need to do following:

~b + 1 (I guess you know ~, i,e changing 1 to 0 and viceversa)

for ex:

+9 in base 10(Decimal) = 0000 1001 in base 2(Binary)
1. ~(+9) = 1111 0110
2. add 1 = 1111 0111 = -9 in binary.

Also remember when you have a binary negative number (Sign bit is 1) then you can 2's complement that and calculate the decimal to findout what number is that.

for ex if somebody asks you what is 1111 0111 in decimal:

now:

1. you know its a negative number (sign bit is 1)

2. 2's complement will be - 0000 1001 -- thats 9 so the original decimal number is -9.

Note: All my examples are in 8 bit format, but Java used 32 bits for integer. Anyway I can assure you that the concept is the same.

Now I guess you can understand how 1111 1011 is -5.

Hope this helps..

Sakti Singh
[ August 16, 2005: Message edited by: Sakti Singh ]
Smitha Ballikar
Ranch Hand

Joined: Aug 02, 2005
Posts: 99
Hi Sakti,

Thanks for your wonderful explanation!!

Cheers
Smitha
 
 
subject: Converting probability
 
Similar Threads
Converting to Hexadecimal literals
Clarify Question
Hexadecimal Literals
conversion
somebody help me this question(Operators)