public static function PHPExcel_Calculation_Engineering::BINTODEC in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php \PHPExcel_Calculation_Engineering::BINTODEC()
* BINTODEC * * Return a binary value as decimal. * * Excel Function: * BIN2DEC(x) * * @access public * @category Engineering Functions *
Parameters
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
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Engineering.php, line 1064
Class
- PHPExcel_Calculation_Engineering
- PHPExcel_Calculation_Engineering
Code
public static function BINTODEC($x) {
$x = PHPExcel_Calculation_Functions::flattenSingleValue($x);
if (is_bool($x)) {
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
}
else {
return PHPExcel_Calculation_Functions::VALUE();
}
}
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) {
$x = floor($x);
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/', $x, $out)) {
return PHPExcel_Calculation_Functions::NaN();
}
if (strlen($x) > 10) {
return PHPExcel_Calculation_Functions::NaN();
}
elseif (strlen($x) == 10) {
// Two's Complement
$x = substr($x, -9);
return '-' . (512 - bindec($x));
}
return bindec($x);
}