code: public static function BINTODEC($x)
      {
          $x = Functions::flattenSingleValue($x);
  
          if (is_bool($x)) {
              if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE) {
                  $x = (int) $x;
              } else {
                  return Functions::VALUE();
              }
          }
          if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
              $x = floor($x);
          }
          $x = (string) $x;
          if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
              return Functions::NAN();
          }
          if (strlen($x) > 10) {
              return Functions::NAN();
          } elseif (strlen($x) == 10) {
              //    Two's Complement
              $x = substr($x, -9);
  
              return '-' . (512 - bindec($x));
          }
  
          return bindec($x);
      }
docs: BINTODEC.
  
  Return a binary value as decimal.
  
  Excel Function:
  BIN2DEC(x)
  
  @category Engineering Functions
  
  @param string $x The binary number (as a string) that you want to convert. The number
  cannot contain more than 10 characters (10 bits). The most significant
  bit of number is the sign bit. The remaining 9 bits are magnitude bits.
  Negative numbers are represented using two's-complement notation.
  If number is not a valid binary number, or if number contains more than
  10 characters (10 bits), BIN2DEC returns the #NUM! error value.
  
  @return string