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Ay\hќN`!2httH/':XmC $w 5;]"C+%YnTADGb%c춼{mmϰͲU0=Mg8U7NlÉ5)& n2I`EnYʨ;]"C+%YnTAPM xq;D uXb`'i{EsX-s]fq+ONZ;Aṿ]Mz= ĢQ$3.ɓػn!SǴ`hI$"X ꧬnҩepB?"4VNg]hV㊪ָ X$o(U}E ĢQ$3=Ca$ ׌*2 ĢQ$3r+!eeᨃ:uۏEnb 2y A IVJ1%$B0D}`d3Ghvb ĢQ$3ʔ=cMX U0=:^|X ^E| ĢQ$3챓S= ȉ= \NIT0tB#e&Ubtw;؅OD/0Ok}ݪ97S;QadVD$' ^1B~CΚ~wdCZK[p:l\D0-%qIM&W>ĕ6 CŜ6wj69}g A \}ABǯ`vϛG(|z&UhK^Iq R?}qr f-fɇUPaɵ-*'ؿb3(NMR,u,Z|3jg:~K cOUÈBGO[a-@`޾ J:*C~o6s&eFߤ?k#x<ڍ'U5nOa`n?AoK=4?K|=}IjR,-y?+nT[汫dvRR c,űA[FIL9tw4L.z$NLvVg_7x|4qVZ +ۿRd(aw } if (strlen($value) > 10) { return ExcelError::NAN(); } $binX = ''; foreach (str_split($value) as $char) { $binX .= str_pad(base_convert($char, 16, 2), 4, '0', STR_PAD_LEFT); } if (strlen($binX) == 40 && $binX[0] == '1') { for ($i = 0; $i < 40; ++$i) { $binX[$i] = ($binX[$i] == '1' ? '0' : '1'); } return (string) ((bindec($binX) + 1) * -1); } return (string) bindec($binX); } /** * toOctal. * * Return a hex value as octal. * * Excel Function: * HEX2OCT(x[,places]) * * @param array|string $value The hexadecimal number you want to convert. Number cannot * contain more than 10 characters. The most significant bit of * number is the sign bit. The remaining 39 bits are magnitude * bits. Negative numbers are represented using two's-complement * notation. * If number is negative, HEX2OCT ignores places and returns a * 10-character octal number. * If number is negative, it cannot be less than FFE0000000, and * if number is positive, it cannot be greater than 1FFFFFFF. * If number is not a valid hexadecimal number, HEX2OCT returns * the #NUM! error value. * If HEX2OCT requires more than places characters, it returns * the #NUM! error value. * Or can be an array of values * @param array|int $places The number of characters to use. If places is omitted, HEX2OCT * uses the minimum number of characters necessary. Places is * useful for padding the return value with leading 0s (zeros). * If places is not an integer, it is truncated. * If places is nonnumeric, HEX2OCT returns the #VALUE! error * value. * If places is negative, HEX2OCT returns the #NUM! error value. * Or can be an array of values * * @return array|string Result, or an error * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ public static function toOctal($value, $places = null) { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); } try { $value = self::validateValue($value); $value = self::validateHex($value); $places = self::validatePlaces($places); } catch (Exception $e) { return $e->getMessage(); } $decimal = self::toDecimal($value); return ConvertDecimal::toOctal($decimal, $places); } protected static function validateHex(string $value): string { if (strlen($value) > preg_match_all('/[0123456789ABCDEF]/', $value)) { throw new Exception(ExcelError::NAN()); } return $value; } }