Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting probability

 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

??
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sergei, what trick?
 
Sergei Iakhnin
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Philip Heller
author
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sakti,

Thanks for your wonderful explanation!!

Cheers
Smitha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic