creating binary numbers and convert to dec.

bkelly

Active Member
Joined
Jan 28, 2005
Messages
465
I am working on a workbook that assists in building data to generate a telemetry string. It seems that I must build the string one "0" or "1" at a time, then convert my sixteen character binary looking string to decimal or hex. But when C3 contains "00010100100" and D3 contains "=BIN2DEC(C3) I get an conversion error.

How do I resolve that?

Just in case someone knows a much more elegant, and maybe built in solution: Another way of looking at the problem is that I need to build a 16 bit number, then change the format from big endian to little endian. When the left 8 bits get moved to the right side, all the leading zeroes must be retained. After the 16 bit word is created, then I need to convert to decimal.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I suspect it's because of the leading 0's.
In Excel, real numbers don't have leading 0's, so it thinks it's text..


Try

=BIN2DEC(C3+0)
 
Upvote 0
Hi Bryan

Bin2Dec() only accepts a maximum of 10 digits. Since you have strings with 16 digits get the value of each of the bytes and compose the result according to the endianness

Ex., for big endian, unsigned:

=bin2dec(RIGHT(A1,8))+256*bin2dec(LEFT(A1,8))
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,696
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top