Skip to main content
added 334 characters in body
Source Link

Don't over-think it with how many powers of 2 you need :


 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

 7      for (__ in ___)
 7          _ += ___[__] + _

 1      return _
    }

1010111 87

You don't need to know how long the input is (as long as precision allows), and the values of powers of 2. In fact, you don't even need to perform a single multiplication or left-shift at all in order to convert binary strings to decimal.

This code does nothing except repeatedly adding a full copy of its accumulator value as well as the next bit, allowing one to perform the conversion using a total of just 3 variables (inclusive of the one required for accepting function input) -

___ : The iterator array

 __ : First as the input string, 

      then also as index of iterator

  _ : First as the empty string regex for splitting the input 
      into iterator array (so each digit occupies its own cell),
      
      then also as the accumulator for the iterator

* It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice. It can just as easily convert this 53-bit binary string back into a 16-(decimal)-digits prime :

 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

53      for (__ in ___)
53          _ += ___[__] + _

 1      return _
    }

11111001011110101011110100110010111001001110001110001 8777777777777777

The same approach can just as easily be adapted for conversion of other bases, such as octals :

function _8_to_10_(__, ___, _) {

    split(__, ___, _ = "")

    for (__ in ___)
        _ += ___[__] + (_ += _ += _)

    return _
}

371365364627116161 8 8777777777777777

Don't over-think it with how many powers of 2 you need :


 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

 7      for (__ in ___)
 7          _ += ___[__] + _

 1      return _
    }

1010111 87

You don't need to know how long the input is (as long as precision allows), and the values of powers of 2. In fact, you don't even need to perform a single multiplication or left-shift at all in order to convert binary strings to decimal.

This code does nothing except repeatedly adding a full copy of its accumulator value as well as the next bit, allowing one to perform the conversion using a total of just 3 variables (inclusive of the one required for accepting function input) -

___ : The iterator array

 __ : First as the input string, 

      then also as index of iterator

  _ : First as the empty string regex for splitting the input 
      into iterator array (so each digit occupies its own cell),
      
      then also as the accumulator for the iterator

* It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice. It can just as easily convert this 53-bit binary string back into a 16-(decimal)-digits prime :

 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

53      for (__ in ___)
53          _ += ___[__] + _

 1      return _
    }

11111001011110101011110100110010111001001110001110001 8777777777777777

Don't over-think it with how many powers of 2 you need :


 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

 7      for (__ in ___)
 7          _ += ___[__] + _

 1      return _
    }

1010111 87

You don't need to know how long the input is (as long as precision allows), and the values of powers of 2. In fact, you don't even need to perform a single multiplication or left-shift at all in order to convert binary strings to decimal.

This code does nothing except repeatedly adding a full copy of its accumulator value as well as the next bit, allowing one to perform the conversion using a total of just 3 variables (inclusive of the one required for accepting function input) -

___ : The iterator array

 __ : First as the input string, 

      then also as index of iterator

  _ : First as the empty string regex for splitting the input 
      into iterator array (so each digit occupies its own cell),
      
      then also as the accumulator for the iterator

* It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice. It can just as easily convert this 53-bit binary string back into a 16-(decimal)-digits prime :

 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

53      for (__ in ___)
53          _ += ___[__] + _

 1      return _
    }

11111001011110101011110100110010111001001110001110001 8777777777777777

The same approach can just as easily be adapted for conversion of other bases, such as octals :

function _8_to_10_(__, ___, _) {

    split(__, ___, _ = "")

    for (__ in ___)
        _ += ___[__] + (_ += _ += _)

    return _
}

371365364627116161 8 8777777777777777
added 1 character in body
Source Link

Don't over-think it with how many powers of 2 you need :


 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

 7      for (__ in ___)
 7          _ += ___[__] + _

 1      return _
    }

1010111 87

You don't need to know how long the input is (as long as precision allows), and the values of powers of 2. In fact, you don't even need to perform a single multiplication or left-shift at all in order to convert binary strings to decimal.

This code does nothing except repeatedly adding a full copy of its accumulator value as well as the next bit, allowing one to perform the conversion using a total of just 3 variables (inclusive of the one required for accepting function input) -

___ : The iterator array

 __ : First as the input string, 

      then also as index of iterator

  _ : First as the empty string regex for splitting the input 
      into iterator array (so each digit occupies its own cell),
      
      then also as the accumulator for the iterator

* It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice. It can just as easily convert this 53-bit binary string back into a 16-(decimal)-digits prime :

 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

53      for (__ in ___)
53          _ += ___[__] + _

 1      return _
    }

11111001011110101011110100110010111001001110001110001 8777777777777777

Don't over-think it with how many powers of 2 you need :


 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

 7      for (__ in ___)
 7          _ += ___[__] + _

 1      return _
    }

1010111 87

You don't need to know how long the input is (as long as precision allows), and the values of powers of 2. In fact, you don't even need to perform a single multiplication or left-shift at all in order to convert binary strings to decimal.

This code does nothing except repeatedly adding a full copy of its accumulator value as well as the next bit, allowing one to perform the conversion using a total of just 3 variables (inclusive of the one required for accepting function input) -

___ : The iterator array

 __ : First as the input string, 

      then also as index of iterator

  _ : First as the empty string regex for splitting the input 
      into iterator array (so each digit occupies its own cell),
      
      then also as the accumulator for the iterator

* It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice.

Don't over-think it with how many powers of 2 you need :


 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

 7      for (__ in ___)
 7          _ += ___[__] + _

 1      return _
    }

1010111 87

You don't need to know how long the input is (as long as precision allows), and the values of powers of 2. In fact, you don't even need to perform a single multiplication or left-shift at all in order to convert binary strings to decimal.

This code does nothing except repeatedly adding a full copy of its accumulator value as well as the next bit, allowing one to perform the conversion using a total of just 3 variables (inclusive of the one required for accepting function input) -

___ : The iterator array

 __ : First as the input string, 

      then also as index of iterator

  _ : First as the empty string regex for splitting the input 
      into iterator array (so each digit occupies its own cell),
      
      then also as the accumulator for the iterator

* It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice. It can just as easily convert this 53-bit binary string back into a 16-(decimal)-digits prime :

 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

53      for (__ in ___)
53          _ += ___[__] + _

 1      return _
    }

11111001011110101011110100110010111001001110001110001 8777777777777777
added 1 character in body
Source Link

don'tDon't over-think it with how many powers of 2 you need :


 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

 7      for (__ in ___)
 7          _ += ___[__] + _

 1      return _
    }

1010111 87

You don't need to know how long the input is (as long as precision allows), and the values of powers of 2. In fact, you don't even need to perform a single multiplication or left-shift at all in order to convert binary strings to decimal. 

This code does nothing except repeatedly adding a full copy of its accumulator value as well as the next bit.

And you can, allowing one to perform binary stringthe conversion using a total of just 3 variables (inclusive of the one required for accepting function input) -

___ : theThe iterator array

 __ : firstFirst as the input string, 

      then also as index of iterator

  _ : firstFirst as the empty string regex for splitting the input 
      into iterator array (so each digit occupyoccupies its own cell),
      
      then also as the accumulator for the iterator

It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice.* It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice.

don't over-think it with how many powers of 2 you need :


 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

 7      for (__ in ___)
 7          _ += ___[__] + _

 1      return _
    }

1010111 87

You don't need to know how long the input is (as long as precision allows), and the values of powers of 2. In fact, you don't even need to perform a single multiplication or left-shift at all in order to convert binary strings to decimal. This code does nothing except repeatedly adding a full copy of its accumulator value as well as the next bit.

And you can perform binary string conversion using a total of just 3 variables (inclusive of the one required for accepting function input) -

___ : the iterator array

 __ : first as the input string, 

      then also as index of iterator

  _ : first as the empty string regex for splitting the input 
      into iterator array (so each digit occupy its own cell),
      
      then also as the accumulator for the iterator

It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice.

Don't over-think it with how many powers of 2 you need :


 1  function ____(__, ___, _) {

 1      split(__, ___, _ = "")

 7      for (__ in ___)
 7          _ += ___[__] + _

 1      return _
    }

1010111 87

You don't need to know how long the input is (as long as precision allows), and the values of powers of 2. In fact, you don't even need to perform a single multiplication or left-shift at all in order to convert binary strings to decimal. 

This code does nothing except repeatedly adding a full copy of its accumulator value as well as the next bit, allowing one to perform the conversion using a total of just 3 variables (inclusive of the one required for accepting function input) -

___ : The iterator array

 __ : First as the input string, 

      then also as index of iterator

  _ : First as the empty string regex for splitting the input 
      into iterator array (so each digit occupies its own cell),
      
      then also as the accumulator for the iterator

* It matters not what language this function is in as presented, because it's generic enough it's easily portable to any language of choice.

Source Link
Loading