Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to represent a binary number size greater than 64 bit

Tags:

c++

binary

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:

  • How do I represent this number in decimal?
  • Is there any free tool available to represent this number?
  • Is there any way in C++11/C++ to achieve this?
like image 410
Atul Avatar asked Jan 28 '26 01:01

Atul


1 Answers

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.

like image 195
Dale Fletter Avatar answered Jan 30 '26 20:01

Dale Fletter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!