Question:
formula for converting decimal to octal, binary to hexadecimal anything like that?
mkk572ny
2008-10-03 08:01:00 UTC
binary, octal, decimal, hexadecimal
Six answers:
jivepacketrat
2008-10-03 08:33:05 UTC
Quick answer, why do you not use the calculator built into your computer for conversions between decimal - binary - octal - or hexadecimal. Programs>Accessories> calculator. When it appears under "View" select scientific. Enter the decimal number with Dec selected then click on Hex, Oct or Bin.

Formula: Converting decimal to octal or hexadecimal:

You asked about octal, so I will use it, but hexadecimal works using 16.

601 decimal to octal

Divide 600 by 8 = 75 and the remainder is 1

Divide 75 by 8 = 9 and the remainder is 3

Divide 9 by 8 =1 and the remainder is 1

Divide 1 by 8 = 0 and the remainder is 1

Reading from bottom to top 300 decimal is 1131 octal.

So keep dividing the number by the base number, until you only have a remainder, then use last remainder as the most significant number..



To change 1131 octal to decimal: Keep the right number, multiply all other digits by the base number times itself the same number of times that it is to the left of your right number..

Right most number 1

Multiply 3 x 8 = 24

Multiply 1 x 8 x 8 = 64

Multiply 1 x 8 x 8 x 8 = 512.

Add your numbers up and you get 601.
2015-08-06 19:45:02 UTC
This Site Might Help You.



RE:

formula for converting decimal to octal, binary to hexadecimal anything like that?

binary, octal, decimal, hexadecimal
green
2016-09-28 04:08:28 UTC
Decimal To Octal
Nabendu Maji
2008-10-03 08:25:39 UTC
Convention:



Decimal to octal: Davide Decimal number by 8 & Count the carries upward.

Example: If we Convert Decimal number 12, then Davide 12 by 8 & you will get carry 4 & rest is 1. So, count upward, answer will be 14 in Octal.



Binary to Hexadecimal: Short Cut method:

If the binary number is 1010110 then in order to convert it in Hexadecimal in shortcut method you need to brake this number by taking four digits at a time.

So, if we do that. it will be. 0101 & 0110 (U need to start it from End of the number by taking four number at a time)

And now convert 0101 to Decimal & answer will be 5 in decimal & conversion of 0110 will be 6.



So, Binary 1010110 in Hexadecimal will be 56.
Susan
2016-04-01 20:17:21 UTC
For the best answers, search on this site https://shorturl.im/au0XF



Hm.... Ciaron right! Use format spesifier to printf() for hex %x and octal%o. Now how to convert dec 2 bin: Here my function: char *dec2bin(int bil,char *bin){ int modus=bil%2; bil/=2; *bin++=modus | 0x30; *(bin+1)=0; if(bil)dec2bin(bil,bin); return bin;} HOW TO? char bin[32];//32bit dec2bin(64,bin); strrev(bin); printf("%s",bin);
Spacious BLue
2008-10-03 08:14:29 UTC
http://www.learn-programming.za.net/articles_decbinhexoct.html


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...