# Converting probability

- 0

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!

- 0

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch

Getting someone to think and try something out is much more useful than just telling them the answer.

- 0

Although, thanks for your reply, it has actually calmed me down a little.

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

Live life to an interface, not an implementation!

- 0

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

- 0

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.

SCJP 1.4, SCWCD 1.4

- 0

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

Ranch Hand

- 0

-- 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".

- 0

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.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch

Getting someone to think and try something out is much more useful than just telling them the answer.

- 0

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

- 0

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!!

- 0

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 ]

It is sorta covered in the JavaRanch Style Guide. |