Atul
Atul

Reputation: 765

How to represent a binary number size greater than 64 bit

I have a binary number which I want to represent in decimal. The number is as follows:

Binary = 1000 11100000 00000000 00000000 00000000 00000000 01101110 10110000 10100101  

Its equivalent hexadecimal representation is as follows :

Hexadecimal = 08 E0 00 00 00 00 6E B0 A5

I am working on Windows 7 and tried using calculator in programmer mode with Bin (Binary) and Qword. However, it has a limit of 64 bit.

Questions:

Upvotes: 3

Views: 5540

Answers (3)

MSalters
MSalters

Reputation: 179819

The easier solution may be to work from the other side. Generate the binary representations of all powers of 10: 0x1, 0xA, 0x64, 0x3E8, 0x2710, ... until the power of 10 is larger than your number. Then, count how many times each power of 10 occurs (up to 9, of course).

So 0x2F would be 4 * 0xA + 7 * 0xA, i.e. 47 decimal.

Upvotes: 0

Dale Fletter
Dale Fletter

Reputation: 76

First determine how large a binary number your platform will support. Let's say it's 64. Divide your binary number into chunks of 64 and do the low-order chunk as normal. Now, the low-order bit of the next chunk represents 264. Convert that chunk like a regular number but multiply it by 264. You could use this technique as many times as you need. The next chunk you would multiply by 2128, then the next by 2192, etc.

Upvotes: 5

akshaykumar6
akshaykumar6

Reputation: 2257

I think you should refer this.

You can use the BigInteger class if you are going for JAVA,here.

Or download this user-defined library for performing calculations over big numbers in C++, here.

Upvotes: 0

Related Questions