Retorna a raiz do valor atual pelo operando indicado.

@param       int $dPlaces
Total de casas decimais a serem levadas em conta.

@return      RealNumber
3872
public function sqrt(int $dPlaces = 0) : RealNumber
    {
        return new RealNumber(bcsqrt($this->value(), $this->useDecimalPlaces($dPlaces)));
    }
622727
public static function toRealNumber($o) : ?RealNumber
    {
        if (RealNumber::isValidRealNumber($o) === true) {
            return new RealNumber($o);
        } else {
            return null;
        }
    }
647357
public function getAdressesMemeLocalite($idAdresse = 0, $typeLocalite = 'rue')
    {
        // lien retour vers l'affichage du detail de l'adresse
        $html="<a href=\"".$this->creerUrl('', 'adresseDetail', array('archiIdAdresse'=>$idAdresse))."\">Retour</a><br>";

        // recuperation des adresses liees
        $reqAdresses = "

            SELECT ha1.idAdresse as idAdresse,ha1.idRue as idRue, ha1.idQuartier as idQuartier, ha1.idSousQuartier as idSousQuartier, ha1.idPays as idPays , ha1.idVille as idVille
            FROM historiqueAdresse ha2, historiqueAdresse ha1
            WHERE ha2.idAdresse = ha1.idAdresse
            AND ha1.idAdresse = '".$idAdresse."'
            GROUP BY ha1.idAdresse, ha1.idHistoriqueAdresse
            HAVING ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse)
        ";

        $res = $this->connexionBdd->requete($reqAdresses);

        $rues = array();
        $quartiers = array();
        $sousQuartiers = array();
        $pays = array();
        $villes = array();
        $sql="";
        $tabIdAdressesNotToDisplay = array();
        $arrayComplementTitre=array();
        if (mysql_num_rows($res)>0) {
            while ($fetch = mysql_fetch_assoc($res)) {
                //$tabAdresses[] = array('idRue'=>$fetch['idRue'],'idQuartier'=>$fetch['idQuartier'],'idSousQuartier'=>$fetch['idSousQuartier'],'idPays'=>$fetch['idPays'],'idVille'=>$fetch['idVille']);
                if ($typeLocalite=="rue") {
                    if ($fetch['idRue']!='0') {
                        $rues[] = $fetch['idRue'];
                    }

                    $arrayComplementTitre[]="à la rue";
                } elseif ($typeLocalite=="quartier") {
                    // recherche du quartier
                    if ($fetch['idRue']!='0') {
                    // recherche du quartier de la rue
                        $reqQuartier = "
                            SELECT q.idQuartier as idQuartier
                            FROM quartier q
                            RIGHT JOIN sousQuartier sq ON sq.idQuartier = q.idQuartier
                            RIGHT JOIN rue r ON r.idSousQuartier = sq.idSousQuartier
                            WHERE r.idRue = '".$fetch['idRue']."'
                        ";

                        $resQuartier = $this->connexionBdd->requete($reqQuartier);

                        while ($fetchQuartier = mysql_fetch_assoc($resQuartier)) {
                            $quartiers[] = $fetchQuartier['idQuartier'];
                        }
                    }

                    if ($fetch['idQuartier']!='0') {
                        $quartiers[] = $fetch['idQuartier'];
                    }

                    $arrayComplementTitre[]="au quartier";
                }

                    $tabIdAdressesNotToDisplay[]=$fetch['idAdresse'];
            }

            if (count($rues)>0) {
                $sql.=" AND ha1.idRue in ('".implode("','", array_unique($rues))."') ";
            }

            if (count($quartiers)>0) {
                $sql.=" AND q.idQuartier in ('".implode("','", array_unique($quartiers))."') ";
            }

            if (count($rues)==0 && count($quartiers)==0) {
                $sql.=" AND ha1.idAdresse ='0' ";
            }


            $sql.=" AND ha1.idAdresse not in ('".implode("','", $tabIdAdressesNotToDisplay)."') ";
        }

        // affichage de la liste des adresses
        $retour = $this->afficherListe(array('sqlSelectionExterne'=>$sql,'titre'=>'Adresses relatives '.implode(",", $arrayComplementTitre).': ','desactivateRedirection'=>1));

        $html .=$retour['html'];

        return $html;
    }
865433
public function addLocation($locations)
     {
         $newItems = AnHelperArray::getIterator($locations);

         foreach ($newItems as $item) {
             if (! $this->locations->find($item)) {
                 $this->locations->insert($item);
             }
         }

         return $item;
     }
1214291
public static function getDecimalPlaces($number) {
		$decimalPlaces = 0;
		while ($number > 1 && $number != 0) {
			$number /= 10;
			$decimalPlaces -= 1;
		}
		while ($number < 1 && $number != 0) {
			$number *= 10;
			$decimalPlaces += 1;
		}
		return $decimalPlaces;
	}
980832
protected function _getCategoryDiscountValue($dPrice)
    {
        $oDiscount = $this->_getSerieDiscount();
        $aBasketItems = $this->_getBasketItems($oDiscount);

        // Basket Item Count and isAdmin check (unable to access property $oOrder->_getOrderBasket()->_blSkipVouchersAvailabilityChecking)
        if (!count($aBasketItems) && !$this->isAdmin()) {
            $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\VoucherException::class);
            $oEx->setMessage('ERROR_MESSAGE_VOUCHER_NOVOUCHER');
            $oEx->setVoucherNr($this->oxvouchers__oxvouchernr->value);
            throw $oEx;
        }

        $oProductPrice = oxNew(\OxidEsales\Eshop\Core\Price::class);
        $oProductTotal = oxNew(\OxidEsales\Eshop\Core\Price::class);

        foreach ($aBasketItems as $aBasketItem) {
            $oProductPrice->setPrice($aBasketItem['price']);
            $oProductPrice->multiply($aBasketItem['amount']);
            $oProductTotal->add($oProductPrice->getBruttoPrice());
        }

        $dProduct = $oProductTotal->getBruttoPrice();
        $dVoucher = $oDiscount->getAbsValue($dProduct);

        return ($dVoucher > $dProduct) ? $dProduct : $dVoucher;
    }
965777
private function getNumberOfSitemap(array $urlEntries)
    {
        $total = count($urlEntries);

        if ($total <= $this->maxPerSitemap) {
            return 1;
        }

        return intval(ceil($total / $this->maxPerSitemap));
    }
1367926
public static function getNumParcelas($total, $maxParcelas, $valor_minimo) {
        $nParcelas = $maxParcelas;

        //verifica o valor minimo permitido para cada parcela
        if (!empty($valor_minimo) && is_numeric($valor_minimo)) {
            $parcPossiveis = floor($total / $valor_minimo);

            if ($parcPossiveis < $nParcelas) {
                $nParcelas = $parcPossiveis;
            }
        }

        return $nParcelas;
    }
1234354
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getFeatureAvId();
                break;
            case 2:
                return $this->getFeatureFeatureTypeId();
                break;
            case 3:
                return $this->getLocale();
                break;
            case 4:
                return $this->getValue();
                break;
            case 5:
                return $this->getCreatedAt();
                break;
            case 6:
                return $this->getUpdatedAt();
                break;
            default:
                return null;
                break;
        } // switch()
    }
1125102
public function div($v, int $dPlaces = 0) : RealNumber
    {
        $d = new RealNumber($v);
        return new RealNumber(bcdiv($this->value(), $d->value(), $this->useDecimalPlaces($dPlaces)));
    }
223013
public function GetDiscountValue()
    {
        $dValue = 0;
        $iTmpPointer = $this->getItemPointer();
        $this->GoToStart();
        while ($oDiscount = $this->Next()) {
            $dValue += $oDiscount->GetValue();
        }

        $this->setItemPointer($iTmpPointer);

        return $dValue;
    }
181770
public static function restoSegundoDvAsbace($chaveAsbace, $primeiroDv)
    {
        $peso = 8;
        $soma = 0;
        $chaveComPrimeiroDv = $chaveAsbace . $primeiroDv;

        //Separação dos números
        for ($i = 0; $i < strlen($chaveComPrimeiroDv); $i++) {
            //Isolando cada dígito
            $digito = substr($chaveComPrimeiroDv, $i, 1);

            if (2 == $peso) {
                $peso = 7;
            } else {
                $peso--;
            }

            //Efetua multiplicação do dígito pelo peso e soma os resultados
            $soma += (int) $digito * $peso;
        }

        //Retorna o resto da divisão do resultado da soma por 11
        return $soma % 11;
    }
624194
public function decrementPosition($count = 1)
    {
        if ($this->isNotInList()) return $this;

        $newPosition = $this->getListifyPosition() - $count;

        if ($newPosition < $this->listifyTop()) {
            $newPosition = $this->listifyTop();
        }

        $this->setListifyPosition($newPosition);

        return $this;
    }
1368730
public function getByPosition($pos)
    {
        switch ($pos) {
            case 0:
                return $this->getId();
                break;
            case 1:
                return $this->getVisible();
                break;
            case 2:
                return $this->getAddress1();
                break;
            case 3:
                return $this->getAddress2();
                break;
            case 4:
                return $this->getAddress3();
                break;
            case 5:
                return $this->getZipcode();
                break;
            case 6:
                return $this->getCity();
                break;
            case 7:
                return $this->getCountryId();
                break;
            case 8:
                return $this->getLatitude();
                break;
            case 9:
                return $this->getLongitude();
                break;
            case 10:
                return $this->getCreatedAt();
                break;
            case 11:
                return $this->getUpdatedAt();
                break;
            case 12:
                return $this->getVersion();
                break;
            case 13:
                return $this->getVersionCreatedAt();
                break;
            case 14:
                return $this->getVersionCreatedBy();
                break;
            case 15:
                return $this->getDealerShedulesIds();
                break;
            case 16:
                return $this->getDealerShedulesVersions();
                break;
            case 17:
                return $this->getDealerContactIds();
                break;
            case 18:
                return $this->getDealerContactVersions();
                break;
            case 19:
                return $this->getDealerContentIds();
                break;
            case 20:
                return $this->getDealerContentVersions();
                break;
            case 21:
                return $this->getDealerFolderIds();
                break;
            case 22:
                return $this->getDealerFolderVersions();
                break;
            case 23:
                return $this->getDealerBrandIds();
                break;
            case 24:
                return $this->getDealerBrandVersions();
                break;
            case 25:
                return $this->getDealerProductIds();
                break;
            case 26:
                return $this->getDealerProductVersions();
                break;
            case 27:
                return $this->getDealerAdminIds();
                break;
            case 28:
                return $this->getDealerAdminVersions();
                break;
            default:
                return null;
                break;
        } // switch()
    }
226547
private function getDirectoryIterator(string $realPath): \SplHeap
    {
        $directoryIterator = new \RecursiveDirectoryIterator(
            $realPath,
            \RecursiveDirectoryIterator::SKIP_DOTS
        );
        $iterator          = new \RecursiveIteratorIterator(
            $directoryIterator,
            \RecursiveIteratorIterator::SELF_FIRST
        );

        return new class($iterator) extends \SplHeap
        {
            public function __construct(\RecursiveIteratorIterator $iterator)
            {
                foreach ($iterator as $item) {
                    $this->insert($item);
                }
            }

            /**
             * @param mixed $item1
             * @param mixed $item2
             *
             * @return int
             */
            protected function compare($item1, $item2): int
            {
                return strcmp((string)$item2->getRealPath(), (string)$item1->getRealPath());
            }
        };
    }
1084152
private function normalizar_impuesto_retenido(array &$datos)
    {
        // copiar montos
        $montos = [];
        foreach ($datos['Detalle'] as &$d) {
            if (!empty($d['CodImpAdic'])) {
                if (!isset($montos[$d['CodImpAdic']]))
                    $montos[$d['CodImpAdic']] = 0;
                $montos[$d['CodImpAdic']] += $d['MontoItem'];
            }
        }
        // si hay montos y no hay total para impuesto retenido se arma
        if (!empty($montos)) {
            if (!is_array($datos['Encabezado']['Totales']['ImptoReten'])) {
                $datos['Encabezado']['Totales']['ImptoReten'] = [];
            } else if (!isset($datos['Encabezado']['Totales']['ImptoReten'][0])) {
                $datos['Encabezado']['Totales']['ImptoReten'] = [$datos['Encabezado']['Totales']['ImptoReten']];
            }
        }
        // armar impuesto adicional o retención en los totales
        foreach ($montos as $codigo => $neto) {
            // buscar si existe el impuesto en los totales
            $i = 0;
            foreach ($datos['Encabezado']['Totales']['ImptoReten'] as &$ImptoReten) {
                if ($ImptoReten['TipoImp']==$codigo) {
                    break;
                }
                $i++;
            }
            // si no existe se crea
            if (!isset($datos['Encabezado']['Totales']['ImptoReten'][$i])) {
                $datos['Encabezado']['Totales']['ImptoReten'][] = [
                    'TipoImp' => $codigo
                ];
            }
            // se normaliza
            $datos['Encabezado']['Totales']['ImptoReten'][$i] = array_merge([
                'TipoImp' => $codigo,
                'TasaImp' => ImpuestosAdicionales::getTasa($codigo),
                'MontoImp' => null,
            ], $datos['Encabezado']['Totales']['ImptoReten'][$i]);
            // si el monto no existe se asigna
            if ($datos['Encabezado']['Totales']['ImptoReten'][$i]['MontoImp']===null) {
                $datos['Encabezado']['Totales']['ImptoReten'][$i]['MontoImp'] = round(
                    $neto * $datos['Encabezado']['Totales']['ImptoReten'][$i]['TasaImp']/100
                );
            }
        }
        // quitar los codigos que no existen en el detalle
        if (isset($datos['Encabezado']['Totales']['ImptoReten']) and is_array($datos['Encabezado']['Totales']['ImptoReten'])) {
            $codigos = array_keys($montos);
            $n_impuestos = count($datos['Encabezado']['Totales']['ImptoReten']);
            for ($i=0; $i<$n_impuestos; $i++) {
                if (!in_array($datos['Encabezado']['Totales']['ImptoReten'][$i]['TipoImp'], $codigos)) {
                    unset($datos['Encabezado']['Totales']['ImptoReten'][$i]);
                }
            }
            sort($datos['Encabezado']['Totales']['ImptoReten']);
        }
    }
1362973
public function number($flags = 0)
    {
        $ret = false;

        if ($number = $this->match(TextTokenizer::NUMBER, $matches, $flags)) {
            $ret = $number;
        }

        return $ret;
    }