settingsAccountsettings
Menusettings

Q: Convert stuff to binary, decimal and hexadecimal numerical systems

+3 votes

Hi, I want to convert some stuff from (and to) binary, decimal and hexadecimal numerical systems. Can you please help me?

  1. Convert 1234d to binary and hexadecimal numeral systems.
  2. Convert 1100101b to decimal and hexadecimal numeral systems.
  3. Convert ABChex to decimal and binary numeral systems.
asked in Other category by user Jolie Ann
retagged by user golearnweb

7 Answers

+1 vote

The fastest way to do it is to use your Window's (for PC users) calculator - the programmers option (in the "View" tab);

But since there are more interesting ways to convert numbers and symbols you can play around; Here are my answers:

1. Convert 1234d to binary and hexadecimal numerical systems:

1234/2 = 617 (0)

617/2 = 308 (1)

308/2 = 154 (0)

154/2 = 77 (0)

77/2 = 38 (1)

38/2 = 19 (0)

19/2 = 9 (1)

9/2 = 4 (1)

4/2 = 2 (0)

2/2 = 1 (0)

1/2 = 0 (1)

Thus, the number 1234d in the binary numerical system will look like: 10011010010

The number 1234d in the hexadecimal numerical system will look like: 4D2


2. Convert 1100101b to decimal and hexadecimal numerical systems:

1100101b=1+4+32+64=101

Thus, the number 1100101 b in the decimal numerical system will look like: 101

The number 1100101 b in the hexadecimal numerical system will look like: 65


3. Convert ABChex to decimal and binary numeral systems:

ABChex in the decimal numerical system will look like: 2748

ABChex in the binary numerical system will look like: 101010111100

 

answered by user paulcabalit
+1 vote

You can also use some easy to use online converters:

1. Decimal to Binary Converter: http://www.binaryhexconverter.com/decimal-to-binary-converter

2. Binary to Decimal Converter: http://www.binaryhexconverter.com/binary-to-decimal-converter

3. Hexadecimal to Binary Converter: http://www.binaryhexconverter.com/hex-to-binary-converter

4. Hexadecimal to Decimal Converter: http://www.binaryhexconverter.com/hex-to-decimal-converter

answered by user john7
+1 vote

I use tables on my desktop, hope they will help you in the future:


TABLE ASCII TO BINARY

 

TABLE ASCII TO DECIMALS

answered by user samfred5830
edited by user golearnweb
+1 vote

You can use while loop to convert int to binary:

using System;

class ConvertInt
{
    static void Main()
    {
        int x = 1234;

        while (x > 0)
        {
            Console.WriteLine(x % 2);
            x = x / 2;
        }
    }
}
answered by user eiorgert
edited by user golearnweb
+1 vote

You can use Convert.ToString for the number 1234:

using System;

class ConvertEasyWayMethod
{
    static void Main()
    {
        Console.WriteLine("Number 1234 in binary is: " + Convert.ToString(1234, 2));
        Console.WriteLine("Number 1234 in hexadecimal is: " + Convert.ToString(1234, 16));
    }
}
answered by user mitko
edited by user golearnweb
0 votes

Unfortunately there is NO formatting string for binary...

For Hexadecimal you can use:

using System;
using System.Linq;

class Formatting
{
    static void Main()
    {
        int number = 1234;
        Console.WriteLine("The number 1234 in HEX is: {0:X}", number);
    }
}

For converting to binary you can use:

using System;
 
class Convert
{
    static void Main()
    {
        Console.WriteLine("Number 1234 in binary is: " + Convert.ToString(1234, 2));
     }
}

 

answered by user golearnweb
+1 vote

You can use Convert.ToString :-) Here's how:

using System;

class VariableInHexadecimalFormat
{
    static void Main()
    {
        int a = 0xFE;
        Console.WriteLine(Convert.ToString(a, 16));//HEX format
        Console.WriteLine(Convert.ToString(a, 2));//BINARY format
        Console.WriteLine(Convert.ToString(a, 10));//DECIMAL format
    }
}
answered by user eiorgert
...