i am familiar with Digital logic and design but i think i forgot a little thing which is 128= 10000000 and how can we decode that a its a negative no i hope u got like 2=00000010 -2=11111110 how can we know at first glance it is negative no because i think we look Left most significant bit which is set 1 then its negative plz clear my doubts with good example
The best thing is, when you go all the way to the end you will reach the Applet where you can play with numbers and perform operations and see the result both in binary and decimal form without having to do it manually. regds. - satya
Take a Minute, Donate an Hour, Change a Life
You are correct in saying that if the leftmost bit is a one, it is a negative number.
11000000 Can u claim it -ve or +ve? Bye. Viki. ------------------ Count the flowers of ur garden,NOT the leafs which falls away!
• Sun Certified Programmer for Java 2 Platform (SCJP2)
• IBM Certified Professional for Object Oriented Analysis and Design with UML
• IBM Certified System Administrator for WebSphere Application Server v5.0
• Certified Business Analysis Professional (CBAP®)
Vikrama you got my question how can we look at the first instance that 11000000 is a negative number i think so it is not a negative number reason being if it is int then int is 32 bit and 24 bit is empty which is on the left side e.g 00000000 00000000 00000000 11000000 so it is not a negative number but in exam they dont write full 32 bit value they just only write 11000000. Correct me if i am Wrong and plz come up with good explanation Thanks ------------------ Regards Farrukh Mahmud
You're absolutely right farrukh. I haven't taken the exam yet, but from the mock exams that I have done, that is exactly the case. What I have found on the questions regarding bits and bit shifting is that you have to watch what kind of primitive type is the result being assigned to. A lot of questions will do bit shifting on int values, then store the result into a byte. Here's an example that will hopefully help, its from the KM book on page 71:
In the example above, the result is implicitly narrowed to a byte value. If you store the value into an int type, it would have been 384. Hope that helps.. [This message has been edited by rick salsa (edited December 20, 2001).]
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad: