• 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

Binary/Octal/Hex and Decimal Number Systems

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
In spite of working on it , I still do not understand them exactly , only a little bit.

Can anyone please explain them shortly by giving examples??

Thanks,

Mert
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the different number systems simply refers to how many digits you can use. humans use 10 digits... 0-9.

to count, we start cycling through them all. when we run out, we start using two digits at a time. when we run out of every possible 2-digit combination, we go to three.

so a number like 243 really means

2*10^2 + 4*10^1 + 3*10^0.

each position simply means a higher power of 10. why powers of 10? becuase we use decimal base.

if we used Octal base, we only get 8 digits (0-7), and we use powers of 8.

245 in octal means

2*8^2 + 4*8^1 + 3*8^0.

hexadecimal uses 16 digits. 0-9 and then a-f. you can see numbers like

2a7 which would mean

2*16^2 + 11*16^1 + 7*16^0
 
mert �zkaya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much for your instructive explanation...

Mert
 
mert �zkaya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
CAn anyone also explain Binary systems by giving some examples?

Thanks,

Mert :roll:
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recently saw this which describes teaching binary to 3rd graders using the Socratic method. I thought it was interesting.

Teaching Binary

Regards, Guy
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Guy Allard:
I recently saw this which describes teaching binary to 3rd graders using the Socratic method. I thought it was interesting.

Teaching Binary

Regards, Guy



That's pretty cool!

mert, you should skip down the page to where the questions start. I think the questions and answers will help you understand binary numbers.

Layne
 
mert �zkaya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I would like to know that why is binary System is prefered instead of decimal System ?
In other words , what is the advantage of using binary System instead of decimal System ??

Thanks,

Mert
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seasier for computers to count in the binary system becausr there are only two states. 0 or 1, off or on, low voltage or high voltage. However you want o think of it. Think of a light switch, it only knows two states, either its off or its on. Its the same reasoning for computers working in the binary system. The computer doesnt have to, or need to keep track of ten different states (0 - 9) just two states (0 -1) off or on.
 
mert �zkaya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok,
GArrret, I understood what you meant. But is there any advantage of using Binary for programmers ??

Thanks,

Mert :roll:
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mert �zkaya:
GArrret, I understood what you meant. But is there any advantage of using Binary for programmers ??



Two things come to mind:

- as the computer uses the binary system anyway, some oddities are easier to understand once you understand the binary system (for example, why 0.1 decimal can't be represented exactly in a float/double).

- you can "misuse" numbers as sets of booleans - by treating every bit of an int as a boolean, for example.
 
mert �zkaya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Garrett Rowe:
It seasier for computers to count in the binary system becausr there are only two states. 0 or 1, off or on, low voltage or high voltage. However you want o think of it. Think of a light switch, it only knows two states, either its off or its on. Its the same reasoning for computers working in the binary system. The computer doesnt have to, or need to keep track of ten different states (0 - 9) just two states (0 -1) off or on.



Hi,
Can anyone give some examples about the hardwares??

Thanks,

Mert
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An other reason you may want to program with binary values...

Something that you might have occasion to do, as a programmer, is set up a bit-register of flags... what I mean is, maybe you have a one-byte (8-bit) set of flags, where each bit represents some toggle in your program....



Then, what you'd want to do is use the "bitwise" operators, OR, AND, XOR (exclusive or), or the bitwise complement. In java the operators are |, &, ^, ~, respectively.

Depending on if you wanted the flag to always toggle, only toggle if off, only toggle if on, etc. you'd use a different operation.

Now, as to the hardware issue, the way microchips work is by deciding if any message is a 1 or a 0 based upon voltage. You could make hardware that appeared to "think" in decimal, but it would be because you designed a hardware abstraction layer that obfusicated the binary qualities from the programmer... there really wouldn't be any point in doing this, as it would be cumbersome, and have less robust functionality than we currently have at our disposal.

 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Someone with the username mert has been trolling on the Sun Forums with these exact same questions as posted by mert �zkaya in these forums. The only difference being that on the Sun forums mert has been more overt by means of cursing and vague threats towards others.

At any rate mert appears to exhibit many troll like tendencies and behaviours. Just warning.

Compare this thread and http://forum.java.sun.com/thread.jspa?threadID=703144&messageID=4076946 for example.
 
mert �zkaya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, Good diagnosis.
It is the rule of my Game...
Be happy , do not worry...
 
Maximilian Xavier Stocker
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mert �zkaya:
Yeah, Good diagnosis.
It is the rule of my Game...
Be happy , do not worry...



When you say "rule of my Game" I can only interpet that to mean that you are confirming that you are in fact a troll. You said this a couple of times at Sun along with "this is a joke".

I don't believe trolls are desired elements here.

And you just sent me a private message that I will be forwarding to a moderator that reads

"We are Muslim ,we are Turk.
We are not afraid of smo. "

Which I can only guess means you are a troll on a jihad. Lovely.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic