aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes determine binary value , concept not clear yet!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "determine binary value , concept not clear yet!!!" Watch "determine binary value , concept not clear yet!!!" New topic
Author

determine binary value , concept not clear yet!!!

kamal jaisingh
Ranch Hand

Joined: Feb 23, 2001
Posts: 39
hi , thx for your reply.
but the entire concept of binary values is yet not clear
to me.
can i get a step by step explantion on how to get binnary value of a smalller
number , , lets say 5 or 10, etc
thx a lot
regards
Kamal
Stevie Kaligis
Ranch Hand

Joined: Feb 04, 2001
Posts: 400
Hi There...,
To convert number to binary, octal or hex number, you must always divide the number with the required base, for your confinience here is the required base for each number system :
binary : base 2
octal : base 8
hex : base 16
Convert 5 to BINARY (base 2):
5 / 2 = 2 remainder : 1
2 / 2 = 1 remainder : 0
1 / 2 = 0 remainder : 1
binary for 5 is : 101
Convert 5 to OCTAL (base 8):
5 / 8 = 0 remainder : 5
octal for 5 is : 005
note : octal numbers are represented by 3 digit
Convert 5 to HEX (base 16):
5 / 16 = 0 remainder : 5
hex for 5 is : 0x0005
note : hex numbers are represented by 4 digit preceeded by 0x

try it for 10...
hope this help
Sahir Shah
Ranch Hand

Joined: Nov 05, 2000
Posts: 158

<HTML>
Maybe this will also help.


Binary
<table border=1 > <td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td >1</td><td>0</td><td>0</td></tr><tr> <td>2<sup>7</td><td>2<sup>6</td><td>2<sup>5</td><td>2<sup>4</td> <td>2<sup>3</td><td>2<sup>2</td><td >2<sup>1</td><td>2<sup>0 </td></tr> <tr><td >128</td> <td >64</td> <td >32</td> <td >16</td> <td >8</td> <td>4</td><td>2</td><td > 1 </td></tr> </table> 64 * 1 + 32 * 1 + 4 * 1 = 100 Octal <table border="1" ;> <tr><td> 0 </td> <td > 0 </td> <td > 0 </td> <td > 0 </td><td >0</td> <td>1</td><td>4</td><td>4</td></tr><tr><td>8<sup>7</td><td>8<sup>6</td> <td>8<sup>5</td><td>8<sup>4</td><td>8<sup>3</td><td>8<sup>2</td><td>8<sup>1</td> <td>8<sup>0</td></tr> <tr><td >2097152</td> <td >262144</td> <td >32768</td> <td>4096</td> <td >512</td> <td >64</td><td>8</td><td>1</td></tr> </table>


64 * 1 + 8 * 4 + 1 * 4 = 100


Just picture this table in your mind when you want a binary representation of a decimal number.
With some practice you will be equally comfortable with binary numbers as you are with decimal numbers.

Cheers

Sahir

http://www.geocities.com/sahirshah/
</HTML>


....
Dilip Varma
Greenhorn

Joined: Feb 11, 2001
Posts: 3
Kamal,
Have a look at the odometer in your car. (It is the counter within the speedometer that tells you how far you have travelled). It is a decimal counter ie. has digits from 0 to 9. Before you start you set it to 0. If you travel 4 km, it shows
0004
After 9 km it shows
0009
After 10 km it shows
0010
and so on.
Now imagine a car whose odometer is binary ie. has only two digits 0 and 1.
The odometer readings will now be
0000 at start
0001 after 1 km
0010 after 2 km
0011 after 3 km
0100 after 4 km
.
.
1000 after 8 km
1001 after 9 km
1010 after 10 km
and so on.
This is how you count in the binary number system.
If you were counting using the octal system, your odometer would have numbers from 0 to 7 only. Hexadecimal systems would have 16 digits 0 to 9, then a to f.
Hope this makes things a bit clearer.
Regards,
Dilip


[This message has been edited by Dilip Varma (edited February 24, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: determine binary value , concept not clear yet!!!