• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to determine a binary value for a number!!?

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
this is regarding binary values .
how r they determined?
now the binary value of 6 is supposed to be 0110
the binary value of 3 is 0011
how r they determined ??
i do not understand how a binary value is defined for a particular number.
pls help.
thx a lot .
regards
Kamal
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.javaranch.com/ubb/Forum24/HTML/008218.html
 
kamal jaisingh
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi , thx for your reply.
but the entire concept of binary values is yet not clear
to me.
can i get an explantion to get binnary value of a smalller
number , , lets say 5 or 10, etc
thx a lot
regards
Kamal
 
huiying li
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to translate a number to binary, you need to break it down to a sum of 2^n s.
5 = 4 + 1 = 1 * 2^2 + 0*2^1 + 1 * 2^0 =>
101 represent 5 in binary.
10 = 8 + 2 = 1 * 2^3 + 0 *2^2 + 1*2^1 + 0*2^0
so 1010 represent ten.
This is the best I can do to explain it. If it is still confusing, I suggest you spend some time with a math book or sit down with someone to go over it. Although I doubt very much we need to know this in actual programming, you do need to understand it for the test.
good luck

[This message has been edited by huiying li (edited February 24, 2001).]
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi kamal,
read from khalid mughal chapter 2 pg 23,24.
regards.
charu.

Originally posted by kamal jaisingh:
hi
this is regarding binary values .
how r they determined?
now the binary value of 6 is supposed to be 0110
the binary value of 3 is 0011
how r they determined ??
i do not understand how a binary value is defined for a particular number.
pls help.
thx a lot .
regards
Kamal


 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kamal,
Check out the following Campfire Stories here on JavaRanch:
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Charu,
Please read the JavaRanch Name Policy and re-register using a name that complies with the rules.
Thanks for your cooperation.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Follow this logic. I came across this some where on the net . It is very simple !!
Start with the decimal and then go on dividing by 2 and recording the remainder. The first remainder becomes LSD but is written from MSD - LSD after convertion is complete
Following example should make clear what I mean.
Let us start with your number i.e 6
6/2 = 3 Remainder is 0 - LSD
3/2 = 1 Remainder is 1
1/2 = 0 Remainder is 1 - MSD
You can put any number of 0 for Most Significant Bits hence the
value becomes is 0110 (written from MSD to LSD)
Did it help you ?
-Sandeep Nachane
------------------- www.tipsmart.com

[This message has been edited by Sandeep Nachane (edited February 27, 2001).]
 
no wonder he is so sad, he hasn't seen this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic