+ Reply to Thread
Results 1 to 8 of 8

Binary to Decimal

Hybrid View

b.yoxall Binary to Decimal 11-09-2017, 11:02 AM
Zer0Cool Re: Binary to Decimal 11-09-2017, 11:35 AM
Special-K Re: Binary to Decimal 11-09-2017, 12:19 PM
shg Re: Binary to Decimal 11-09-2017, 12:27 PM
Special-K Re: Binary to Decimal 11-09-2017, 12:47 PM
shg Re: Binary to Decimal 11-09-2017, 01:40 PM
Root_ Re: Binary to Decimal 11-09-2017, 02:49 PM
daddylonglegs Re: Binary to Decimal 11-09-2017, 04:48 PM
  1. #1
    Registered User
    Join Date
    04-20-2016
    Location
    London
    MS-Off Ver
    Mac
    Posts
    6

    Binary to Decimal

    Hi,

    I have a 32bit binary number and I need to convert it to a decimal number, the standard BIN2DEC does not work as the number is too large, any assistance?

    Ben

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Binary to Decimal

    Excel is the wrong tool for dealing with extremely large and/or precise numbers.

    Excel can only handle I believe 14/15 digits of significance after which point it truncates beyond those characters. Its also a grey area as to where this happens (final value in a cell definitely, using the results of a calculation mid calc maybe works until the end, etc).

    Testing this is simple, type in a blank cell digits (say 20 digits to make a whole number) and hit enter, then look at the number you entered...it will have trailing 0's now.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,077

    Re: Binary to Decimal

    Working on this...
    Last edited by Special-K; 11-09-2017 at 12:22 PM.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Binary to Decimal

    If the binary strings are always 32 characters (i.e., leading zeros as needed), then

    A
    B
    2
    01111110001111010000011101010001
    2117928785
    3
    11001111111111110101111011001010
    3489619658
    4
    10010100101100000110101100101111
    2494589743
    5
    00110101010000101000011110110010
    893552562
    6
    10100011010110100110000101110000
    2740609392
    7
    11100001100101100010000111011111
    3784712671
    8
    01110100011011101100111101010011
    1953419091
    9
    00101011111000101101010101000010
    736286018
    10
    11111110111101100100000111001001
    4277551561
    11
    01111011000110101111110010101111
    2065366191
    12
    01100010100100110110011010111011
    1653827259


    The formula in B1 is

    =SUMPRODUCT(MID(A2, {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}, 1)
    * 2^{31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0})

    If they vary in length,

    A
    B
    2
    11100100101
    1829
    3
    110100000100110
    26662
    4
    100001101111000010001
    1105425
    5
    111011011001110111010110
    15572438
    6
    1001011110100000010110100
    19873972
    7
    1101111110000
    7152


    =SUMPRODUCT(MID(RIGHT(REPT(0,31) & A2, 32),
    {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32}, 1) *
    2^{31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0})
    Last edited by shg; 11-09-2017 at 12:37 PM.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,077

    Re: Binary to Decimal

    Here ya go

    Input A1 as a string (string can be almost any length)
    Converts binary to decimal
    All my own work!

    =SUMPRODUCT(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)*(2^(LEN(A$1)-ROW(INDIRECT("1:"&LEN(A1))))))

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Binary to Decimal

    The formula I started with was

    =SUMPRODUCT(MID(A2, RowVec(1, LEN(A2)), 1) * 2^RowVec(LEN(A2) - 1, 0))

    ... but that uses a UDF. INDIRECT is compact but volatile.
    Last edited by shg; 11-09-2017 at 01:43 PM.

  7. #7
    Valued Forum Contributor Root_'s Avatar
    Join Date
    07-29-2017
    Location
    _
    MS-Off Ver
    2010+
    Posts
    514

    Re: Binary to Decimal

    Here is a non-volatile version:

    =SUMPRODUCT(MID(A1,ROW(A$1:INDEX(A:A,LEN(A1))),1)*(2^(LEN(A1)-ROW(A$1:INDEX(A:A,LEN(A1))))))

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,697

    Re: Binary to Decimal

    Assuming 32 characters you could split the string (within the formula) and use BIN2DEC on each section, e.g. with this formula

    =SUM(BIN2DEC(MID(A2,{1,9,17,25},8))*2^{24,16,8,0})
    Audere est facere

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Binary to decimal converter
    By SavageMind in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-15-2016, 05:12 PM
  2. [SOLVED] Signed Binary Decimal (B16) Conversion
    By Talamon in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-15-2014, 03:34 PM
  3. Excel Binary to Decimal
    By madushana in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-19-2013, 01:00 PM
  4. Binary to Decimal converter
    By thedudester1978 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2012, 12:42 PM
  5. Converts a decimal number to binary
    By sricomm in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 10-09-2006, 10:37 PM
  6. decimal to binary
    By boardmaker in forum Excel General
    Replies: 4
    Last Post: 06-13-2006, 04:10 PM
  7. [SOLVED] decimal to binary conversion
    By tam in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-29-2005, 01:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1