• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Binary Play

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

------------------
Regards
Farrukh Mahmud
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi farrukh,
You are correct in saying that if the leftmost bit is a one, it is a negative number. The Campfire has a good story on bits. It helped me out.
-rick
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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!
 
farrukh mahmud
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rick Salsa
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic