Computing.Net > Forums > Programming > Binary/octal/ect... conversions.

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Binary/octal/ect... conversions.

Reply to Message Icon

Name: C++ causes headaches
Date: September 2, 2003 at 13:20:49 Pacific
OS: xp
CPU/Ram: 780
Comment:

I have to figure out how to convert binary to octal and converions from decimal to binary and things of this nature. I have done this before, but it was a long time ago. I did a search on a few of the popular search engines for "binary conversion tutorial" and didn't see much returned that was usful. Does anyone know of a web site that is good for finding such tutorials? If so, it will be a great help. Thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: anonproxy
Date: September 2, 2003 at 17:00:46 Pacific
Reply:

The way humans understand it:
http://www.dark-logic.com/pgm/binary.html

And the way computers understand it:
http://www.goshen.edu/compsci/mis200/decbinary.htm
http://computing.net/programming/wwwboard/forum/4822.html

And for hex:
http://dbforums.com/t843665.html
http://www.computing.net/programming/wwwboard/forum/3613.html

There are number libraries for all languages. Take one of these and look at the source code if you want to know how the functions handle the conversion.


0

Response Number 2
Name: dtech10
Date: September 2, 2003 at 17:12:47 Pacific
Reply:

Hi

Converting from Decimal is the most involved.
Use somthing like this to convert from any base.

Input Number
Input Base

While Number>0
Remainder= Number modulus Base
Number=Int(Number/Base)
Print Remainder;" ";
endwh

Note: The values from Remainder are output in the reverse order, it's just a question of reversing them.
For Hex you will have to change 10-15 to A-F, just add 55 and print the askii value for these.


Changing from Binary to Octal to Hex is quite easy

ie decimal 63022 in binary=1111011000101110
for Octal just split it up into 3's starting from the right hand side and convert to their decimal values.
ie 1 111 011 000 101 110
1 7 3 0 5 6 =173056 Octal

for Hex do the same but this time into 4's
ie 1111 0110 0010 1110
15 6 2 14 =F62D Hex
F 6 2 D

ie Octal to Hex or Hex to Octal
convert to binary and split it up into 3's or 4's
by reversing the above process.
Hope this helps


0

Response Number 3
Name: SN
Date: September 2, 2003 at 20:14:45 Pacific
Reply:

These are some great sites that I think convert between bases pretty nicely:
this one and
this one is way cool...It not only does the base conversions but also gives you a step by step explanation. Both sites are javascript base so they're pretty user friendly.

Of course, these will do the work for you, but you know you need to learn how to do it by hand as well. I'm sure the links posted by previous guys are more than sufficient. The second link I posted should help as well.

Good luck, and get some tylenol for those headaches! Or switch to Perl:-)

-SN


0

Response Number 4
Name: C++ causes headaches
Date: September 3, 2003 at 17:02:10 Pacific
Reply:

Thanks. Theses websites are just what i needed to prictice theses conversions. Thanks again!!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Binary/octal/ect... conversions.

converting to binary,octal,hexa www.computing.net/answers/programming/converting-to-binaryoctalhexa/11823.html

Language Purpose www.computing.net/answers/programming/language-purpose/7752.html

C++ Coding question www.computing.net/answers/programming/c-coding-question/7769.html