/** * * @return type json dell' array dei prodotti della home */ public function ProdottiInEvidenza() { $ProdottoDAO = new FProdotto(); $risultato = $ProdottoDAO->ContaProdotti(); $risultato = $risultato[0]["COUNT(Id)"]; //Risultato contiene il num di prodotti presenti nel Catalogo $Indicicasuali = array(); for ($index = 0; $index < 6; $index++) { $Indicicasuali[] = rand(1, $risultato); } $Indicicasuali = array_unique($Indicicasuali); while (count($Indicicasuali) < 6) { $Indicicasuali[] = rand(1, $risultato); $Indicicasuali = array_unique($Indicicasuali); } $CRicercaProdotto = new CRicercaProdotto(); $ArrayProdotti = array(); foreach ($Indicicasuali as $key => $value) { for ($i = 0; $i < 2 - log10($value); $i++) { $value = "0" . $value; } $value = "P" . $value; $ArrayProdotti[] = $CRicercaProdotto->RicercaPerId($value); } $JsonRisultato = json_encode($ArrayProdotti); return $JsonRisultato; }
/** * Decode a geohash and return an array with decimal lat,long in it */ public function decode($hash) { //decode hash into binary string $binary = ""; $hl = strlen($hash); for ($i = 0; $i < $hl; $i++) { $binary .= $this->codingMap[substr($hash, $i, 1)]; } //split the binary into lat and log binary strings $bl = strlen($binary); $blat = ""; $blong = ""; for ($i = 0; $i < $bl; $i++) { if ($i % 2) { $blat = $blat . substr($binary, $i, 1); } else { $blong = $blong . substr($binary, $i, 1); } } //now concert to decimal $lat = $this->binDecode($blat, -90, 90); $long = $this->binDecode($blong, -180, 180); //figure out how precise the bit count makes this calculation $latErr = $this->calcError(strlen($blat), -90, 90); $longErr = $this->calcError(strlen($blong), -180, 180); //how many decimal places should we use? There's a little art to //this to ensure I get the same roundings as geohash.org $latPlaces = max(1, -round(log10($latErr))) - 1; $longPlaces = max(1, -round(log10($longErr))) - 1; //round it $lat = round($lat, $latPlaces); $long = round($long, $longPlaces); return array($lat, $long); }
/** * @dataProvider twoAxisDataProvider **/ public function testTwoAxis($firstAxisData, $secondtAxisData, $result) { foreach ($result as $chartClass => $expectedString) { $views = GoogleChartDataSet::create()->setData($firstAxisData); $clicks = GoogleChartDataSet::create()->setData($secondtAxisData); $chart = new $chartClass(); if ($chart->getData()->isNormalized()) { if ($views->getMax() >= 10) { $base = pow(10, floor(log10($views->getMax()))); } else { $base = 0.1; } $views->setBase($base); if ($clicks->getMax() >= 10) { $base = pow(10, floor(log10($clicks->getMax()))); } else { $base = 0.1; } $clicks->setBase($base); } $viewAxis = GoogleChartAxis::create(new GoogleChartAxisType(GoogleChartAxisType::Y))->setRange($views->getMinMax()); $clickAxis = GoogleChartAxis::create(new GoogleChartAxisType(GoogleChartAxisType::R))->setRange($clicks->getMinMax()); if ($chart->getData()->isNormalized()) { $viewAxis->setInterval($views->getBase()); $clickAxis->setInterval($clicks->getBase()); } $chart->setSize(GoogleChartSize::create()->setWidth(300)->setHeight(300))->addAxis($viewAxis)->addLine(GoogleChartLine::create()->setTitle('Показы')->setColor(Color::create('336699'))->setValue($views))->addAxis($clickAxis)->addLine(GoogleChartLine::create()->setTitle('Клики')->setColor(Color::create('339911'))->setValue($clicks)); $this->assertEquals($expectedString, $chart->toString()); } }
/** * Determine if the integer is palindromic. This works by comparing the most significant and least significant digits * at each iteration for equality. If they are equal it keeps iterating. If it makes it half-way through the integer * with no differences, the integer is palindromic. * The most significant digit is found by dividing the integer by 10^the number of digits in the integer. If the * integer is 98789 then the number of digits is 5, then 98789 is divided by 10^4(10000). This results in * 98789 / 10000 = 9.8789. This value is treated as an integer so it's just 9. * The least significant digit is found by calculating the modulo of the integer and 10. If the integer is 98789 then * this results in 98789 % 10 = 9. * If the digits match in an iteration then the modulo of the original iterator and 10^the number of digits in the * integer is found. This becomes the new integer value. If the integer is 98789 then this results in 98789 % 10000 = * 8789. Then the copy of the original integer is divided by 10 to remove the least significant digit. If the copy of * the original integer is 98789 this results in 98789 / 10 = 9878.9. This is treated as an integer so it's just 9878. * After this happens we have two new integers, 8789 and 9878 which are the result of the original integer 98789 with * the most significant and least significant digits stripped, respectively. * * If the number is 98789: * $numberOfDigits = 5 * $msdShift = 10000 * * Iteration 1: * 98789 / 10000 = 9.8789 rounded to 9 AND 98789 % 10 = 9 so we continue * $integer = 98789 % 10000 = 8789 * $msdShift = 10000 / 10 = 1000 * $integerRemaining = 98789 / 10 = 9878 * * Iteration 2: * 8789 / 1000 = 8.789 rounded to 8 AND 9878 % 10 = 8 so we continue * $integer = 8789 % 1000 = 789 * $msdShift = 1000 / 10 = 100 * $integerRemaining = 9878 / 10 = 987 * * Iteration 3: * 789 / 100 = 7.89 rounded to 7 AND 987 % 10 = 7 so we continue * $integer = 789 % 100 = 89 * $msdShift = 100 / 10 = 10 * $integerRemaining = 987 / 10 = 98 * * Iteration 4: * 89 / 10 = 8.9 rounded to 8 AND 98 % 10 = 8 so we continue * $integer = 89 % 10 = 9 * $msdShift = 10/10 = 1 * $integerRemaining = 98 / 10 = 9 * * We have reached the middle so we are done, 98789 is palindromic * * * If the number is 9587: * $numberOfDigits = 4 * $msdShift = 1000 * * Iteration 1: * 9587 / 1000 = 9.587 rounded to 9 AND 9587 % 10 = 7 so 9587 is not a palindrome * * @param $integer * @return bool */ function isPalindromic($integer) { if (!is_numeric($integer)) { throw new \InvalidArgumentException('$integer must be a number'); } $integer = (int) $integer; if ($integer < 0) { return false; } if ($integer === 0) { return true; } $numberOfDigits = floor(log10($integer)) + 1; $integerRemaining = $integer; $msdShift = pow(10, $numberOfDigits - 1); for ($i = 0; $i < $numberOfDigits / 2; $i++) { if ((int) ($integer / $msdShift) != (int) ($integerRemaining % 10)) { return false; } $integer %= $msdShift; $msdShift /= 10; $integerRemaining /= 10; } return true; }
public function actionView($id) { if ($id <= 0) { $this->goHome(); } $allCategory = Category::find()->asArray()->all(); $arrayCategoryIdName = ArrayHelper::map($allCategory, 'id', 'name'); $arrSubCat = Category::getArraySubCatalogId($id, $allCategory); /****** 价格筛选 ****/ $result = (new Query())->select('min(price) as min, max(price) as max')->from('product')->where(['category_id' => $arrSubCat, 'status' => Status::STATUS_ACTIVE])->one(); $min = $result['min']; $max = $result['max']; if ($max > $min && $max > 0) { // 计算跨度 $priceGrade = 0.0001; for ($i = -2; $i < log10($max); $i++) { $priceGrade *= 10; } $span = ceil(($max - $min) / 5 / $priceGrade) * $priceGrade; if ($span == 0) { $span = $priceGrade; } // 计算价格的起点和终点 for ($i = 1; $min > $span * $i; $i++) { } for ($j = 1; $min > $span * ($i - 1) + $priceGrade * $j; $j++) { } $priceFilter['start'] = $span * ($i - 1) + $priceGrade * ($j - 1); for (; $max >= $span * $i; $i++) { } $priceFilter['end'] = $span * $i + $priceGrade * ($j - 1); $priceFilter['span'] = $span; } /****** 价格筛选 end ****/ /****** 品牌筛选 start ****/ $result = (new Query())->select('distinct(brand_id)')->from('product')->where(['category_id' => $arrSubCat, 'status' => Status::STATUS_ACTIVE])->all(); $ids = ArrayHelper::map($result, 'brand_id', 'brand_id'); $brandFilter = Brand::find()->where(['id' => $ids])->orderBy(['name' => SORT_ASC])->all(); /****** 品牌筛选 end ****/ $query = Product::find()->where(['category_id' => $arrSubCat, 'status' => Status::STATUS_ACTIVE]); // 如果选择了价格区间 if (Yii::$app->request->get('max')) { $min = intval(Yii::$app->request->get('min')); $max = intval(Yii::$app->request->get('max')); if ($min >= 0 && $max) { $query->andWhere(['and', ['>', 'price', $min], ['<=', 'price', $max]]); } } // 如果选择了品牌 if (Yii::$app->request->get('brand_id')) { $brandId = intval(Yii::$app->request->get('brand_id')); if ($brandId >= 0) { $query->andWhere(['brand_id' => $brandId]); } } // 侧边热销商品 $sameCategoryProducts = Product::find()->where(['category_id' => $id])->orderBy(['sales' => SORT_DESC])->limit(5)->all(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => Yii::$app->params['defaultPageSizeProduct']], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]); return $this->render('view', ['model' => $this->findModel($id), 'allCategory' => $allCategory, 'arrayCategoryIdName' => $arrayCategoryIdName, 'products' => $dataProvider->getModels(), 'pagination' => $dataProvider->pagination, 'priceFilter' => isset($priceFilter) ? $priceFilter : null, 'brandFilter' => $brandFilter, 'sameCategoryProducts' => $sameCategoryProducts]); }
function pctcolour($pct) { if ($pct == 100) { $fg = 'white'; $bg = 'black'; } if ($pct < 100) { $grn = (2.0 - log10($pct)) * 255; if ($grn < 0) { $grn = 0; } if ($grn > 255) { $grn = 255; } if ($grn > 190) { $fg = 'blue'; } else { $fg = 'white'; } $bg = sprintf("#00%02x00", $grn); } if ($pct > 100) { $red = (log10(pow($pct, 4.0)) - 8.0) / 3.0 * 255; if ($red < 0) { $red = 0; } if ($red > 255) { $red = 255; } $fg = 'white'; $bg = sprintf("#%02x0000", $red); } return array($fg, $bg); }
function Generate($level) { if ($level <= 3) { $base = rand(2, 3); $result = rand(5, 10); } elseif ($level <= 6) { $base = rand(4, 5); $result = rand(10, 15); } else { $base = rand(6, 7); $result = rand(15, 20); } // // Original exercise // $base = 2; // $result = 10; $question = 'Oldja meg a következő egyenletet a valós számok halmazán! Válaszát három tizedesjegyre kerekítve adja meg!$$' . $base . '^x=' . $result . '$$'; $exponent1 = log10($result) / log10($base); $exponent2 = round2($exponent1, 5); $correct = round2($exponent1, 3); $solution = '$' . $correct . '$'; $page[] = 'Vegyük mindkét oldal $10$-es alapú logaritmusát:$$\\log_{10}\\left(' . $base . '^x\\right)=\\log_{10}' . $result . '$$'; $page[] = '<div class="alert alert-info"><strong>Logaritmus azonossága:</strong><br />Hatvány logaritmusa egyenlő az alap logaritmusának és a kitevőnek a szorzatával:$$\\log_ab^k=k\\cdot\\log_ab$$</div>'; $page[] = 'Az azonosság felhasználásával át tudjuk írni a baloldali kifejezést:$$x\\cdot\\log_{10}' . $base . '=\\log_{10}' . $result . '$$'; $hints[] = $page; $page = []; $page[] = 'Osszuk el mindkét oldalt $\\log_{10}' . $base . '$-' . With($base) . '!$$x=\\frac{\\log_{10}' . $result . '}{\\log_{10}' . $base . '}\\approx' . $exponent2 . '$$'; $page[] = '<b>Megjegyzés</b>: a számológépen a tízes alapú logaritmust a <b>log</b> gomb jelöli:<div class="text-center"><kbd>' . $result . '</kbd> <kbd>log</kbd> <kbd>÷</kbd> <kbd>' . $base . '</kbd> <kbd>log</kbd> <kbd>=</kbd></div>'; $page[] = 'A megoldás három tizedesjegyre kerekített értéke <span class="label label-success">$' . $correct . '$</span>.'; $hints[] = $page; return array('question' => $question, 'correct' => $correct, 'solution' => $solution, 'hints' => $hints); }
function convfunc($valtoconv, $convtowhat) { if ($valtoconv == 0) { return 0; } if (strlen($valtoconv) == 1) { return $valtoconv; } switch ($convtowhat) { case 1: $a = $valtoconv / 20.0; $b = pow(10, $a); $c = $b * sqrt(8); $x = $c; error_log("a = {$a}, b = {$b}, c = {$c}"); return $x; case 2: $a = $valtoconv / sqrt(8); $b = log10($a); $c = 20.0 * $b; $x = $c; error_log("a = {$a}, b = {$b}, c = {$c}"); return $x; default: return $valtoconv; } }
public function FromReal($aVal, $aPrecision = 2) { // Convert a floating point number to scientific notation $neg = 1.0; if ($aVal < 0) { $neg = -1.0; $aVal = -$aVal; } $l = floor(log10($aVal)); $a = sprintf("%0." . $aPrecision . "f", round($aVal / pow(10, $l), $aPrecision)); $a *= $neg; if ($this->iSimple && ($a == 1 || $a == -1)) { $a = ''; } if ($a != '') { $this->t = $a . ' * 10'; } else { if ($neg == 1) { $this->t = '10'; } else { $this->t = '-10'; } } $this->iSuper = $l; }
public function decode($hash) { $binary = ""; $hl = strlen($hash); for ($i = 0; $i < $hl; $i++) { $binary .= $this->codingMap[substr($hash, $i, 1)]; } $bl = strlen($binary); $blat = ""; $blong = ""; for ($i = 0; $i < $bl; $i++) { if ($i % 2) { $blat = $blat . substr($binary, $i, 1); } else { $blong = $blong . substr($binary, $i, 1); } } $lat = $this->binDecode($blat, -90, 90); $long = $this->binDecode($blong, -180, 180); $latErr = $this->calcError(strlen($blat), -90, 90); $longErr = $this->calcError(strlen($blong), -180, 180); $latPlaces = max(1, -round(log10($latErr))) - 1; $longPlaces = max(1, -round(log10($longErr))) - 1; $lat = round($lat, $latPlaces); $long = round($long, $longPlaces); return array($lat, $long); }
/** * From roman to decimal numeral system * * @param string $sRoman * @return integer 0 on failure. */ public static function toDecimal($sRoman) { if (!is_string($sRoman)) { return 0; } $iStrLen = strlen($sRoman); $iDoubleSymbol = $iDec = $iPos = 0; foreach (self::$asRomanTransTable as $iNum => $sSymbol) { $iLen = strlen($sSymbol); $iCount = 0; if ($iDoubleSymbol) { --$iDoubleSymbol; continue; } # Mind the fact that 1000 in the Roman numeral system may be represented by M or i. while (($sChunk = substr($sRoman, $iPos, $iLen)) == $sSymbol || $iNum < 10000.0 && $sChunk == strtr($sSymbol, 'iM', 'Mi')) { if ($iLen == 2) { $iDoubleSymbol = 3 - 2 * ($iNum % 3); } $iDec += $iNum; $iPos += $iLen; # All symbols that represent 1eX may appear at maximum three times. All other symbols may only represent one time in a roman number. if (fmod(log10($iNum), 1) || ++$iCount == 3) { break; } } if ($iPos == $iStrLen) { break; } } # If there are symbols left, then the number was mallformed (following default rules (M = 1000 and i = 1000)). return $iPos == $iStrLen ? $iDec : 0; }
/** {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $type = $input->getOption('type'); if (!in_array($type, array('error', 'exception'))) { throw new \LogicException('Type must be either "error" or "exception"'); } $count = intval($input->getOption('count')); $digits = floor(log10($count) + 1); /** @var ErrorHandler $errorHandler */ $errorHandler = $this->getContainer()->get('error_handler'); $metadata = new Metadata(); $metadata->addCategories($input->getArgument('category')); $output->writeln('<fg=cyan>Creating errors</fg=cyan>'); for ($i = 1; $i <= $count; ++$i) { switch ($type) { case 'error': $error = new ErrorException('TEST ERROR', E_USER_ERROR, __FILE__, __LINE__); $errorHandler->handleError($error, $metadata); break; case 'exception': $errorHandler->handleException(new \Exception(), $metadata); break; } $output->writeln(sprintf("<comment>[%{$digits}d/%{$digits}d]</comment> <info>OK</info>", $i, $count)); } $output->writeln('<info>DONE</info>'); }
/** * Set the power * * @param int p power * @throws lang.IllegalArgumentException in case the parameter p contains an illegal value */ public function setPoweredBy($p) { if (!($x = log10($p / 6.1)) || floor($x) != $x) { throw new IllegalArgumentException($p . ' not allowed'); } $this->poweredBy = $p; }
function good_125step($x) { $n = (int) floor(log10($x)); $residue = $x / pow(10, $n); # Equality test on floats isn't usually safe, but it works here. return $residue == 1 || $residue == 2 || $residue == 5; }
function radixSortInt($array) { $maxPow = floor(log10(max($array))); for ($i = 0; $i <= $maxPow; $i++) { // makes an array of buckets to sort mod into $bucketArray = []; for ($j = -9; $j < 10; $j++) { $bucketArray[$j] = 0; } foreach ($array as $element) { $bucketArray[$element / 10 ** $i % 10]++; } $bucketArray[-9]--; for ($j = -8; $j < 10; $j++) { $bucketArray[$j] += $bucketArray[$j - 1]; } $arraySorted = $array; for ($j = count($array) - 1; $j >= 0; $j--) { $arraySorted[$bucketArray[$array[$j] / 10 ** $i % 10]] = $array[$j]; $bucketArray[$array[$j] / 10 ** $i % 10]--; } $array = $arraySorted; } return $array; }
protected function computeResult($_diff) { if (!$_diff) { $this->isIdentical = true; return; } $this->ratio = 10 * log10(pow(255, 2) * $this->imageA->getWidth() * $this->imageA->getHeight() / $_diff); }
public function __construct(FileStorage $storage, $size, $length) { $this->storage = $storage; $this->size = $size; $this->length = $length; $this->addressLength = ceil(log10($size)); $this->fullLength = $this->length + $this->addressLength; }
/** * Set the power * * @param int p power * @throws lang.IllegalArgumentException in case the parameter p contains an illegal value */ public function setPoweredBy($p) { $x = log10($p / 61); if (floor($x) !== $x) { throw new \lang\IllegalArgumentException($p . ' not allowed'); } $this->poweredBy = $p; }
public function convert($number) { if ($number === 0) { return 'Zero'; } elseif ($number <= 9) { // 0 - 9 return ucfirst($this->ones[intval($number)]); } elseif ($number >= 11 && $number <= 19) { // 11 - 19 return ucfirst($this->elevens[intval($number % 10)]); } elseif ($number <= 90 && $number % 10 == 0) { // 10, 20, 30, 40, 50, 60, 70, 80, 90 return ucfirst($this->tens[intval($number / 10)]); } elseif ($number >= 21 && $number <= 99 && !($number % 10) == 0) { // 21-99 return ucfirst($this->tens[intval(substr($number, -2, 1))]) . ' ' . ucfirst($this->ones[intval($number % 10)]); } elseif ($number % 100 == 0) { if (strlen($number) % 2 == 0 || strlen($number) == 3) { // Something like thousand, lakh... $divisor = '1'; for ($i = 1; $i <= strlen($number) - 1; $i++) { $divisor .= '0'; } $tada = ucfirst($this->ones[intval($number / $divisor)]) . ' ' . ucfirst($this->lots[intval(log10($number) + 1)]); $number = substr($number, 1, strlen($number) - 1); } elseif (strlen($number) % 2 == 1) { // Something like ten thousand, ten lakh... $divisor = '1'; for ($i = 1; $i <= strlen($number) - 2; $i++) { $divisor .= '0'; } $tada = $this->convert($number / $divisor) . ' ' . ucfirst($this->lots[intval(log10($number) + 1)]); $number = substr($number, 2, strlen($number) - 2); } $tada .= ' ' . $this->convert($number); return $tada; } elseif ($number > 100 && !($number % 100) == 0) { if (strlen($number) % 2 == 0 || strlen($number) == 3) { // Something like thousand, lakh... $replacement = 0; for ($i = 1; $i < strlen($number) - 1; $i++) { $replacement .= '0'; } $words = $this->convert(substr_replace($number, $replacement, 1, strlen($number) - 1)); $number = substr($number, 1, strlen($number) - 1); } elseif (strlen($number) % 2 == 1) { // Something like ten thousand, ten lakh... $replacement = 0; for ($i = 1; $i < strlen($number) - 2; $i++) { $replacement .= '0'; } $words = $this->convert(substr_replace($number, $replacement, 2, strlen($number) - 2)); $number = substr($number, 2, strlen($number) - 2); } $words .= ' ' . $this->convert($number); return $words; } }
/** * Round numbers using significant digits * * @param float $number The number to round * @param int $n The significant digits to keep * * @return float */ static function roundSig($number, $n = 4) { if ($number == 0) { return 0; } $d = ceil(log10(abs($number))); $power = $n - $d; return round($number, $power); }
function dwp($tmpf, $relh) { if ($relh == 0) { return ""; } $tmpk = 273.15 + 5.0 / 9.0 * ($tmpf - 32.0); $dwpk = $tmpk / (1 + 0.000425 * $tmpk * -log10($relh / 100.0)); return round(($dwpk - 273.15) * 9.0 / 5.0 + 32, 0); }
/** * <pre> * 파일 용량 표기 포맷터 * </pre> * * @param size * @return string */ public static function readableFileSize($size) { if ($size <= 0) { return "0"; } $units = array("B", "KB", "MB", "GB", "TB"); $digitGroups = (int) (log10($size) / log10(1024)); return sprintf("%.2f", $size / pow(1024, $digitGroups)) . $units[$digitGroups]; }
function suffixNumFormat($number) { $prefixes = 'kMGTPEZY'; if ($number >= 1000) { $log1000 = floor(log10($number) / 3); return floor($number / pow(1000, $log1000)) . $prefixes[$log1000 - 1]; } return $number; }
public function __construct($value) { $this->value = self::asNative($value); if ($this->value == 0) { $this->digitCount = 1; } else { $this->digitCount = 1 + floor(log10(abs($this->value))); } }
/** * Efficiently calculates how many digits the integer portion of a number has. * * @access public * @param int $number * @return int $digits */ public static function number_of_digits($number) { $log = log10($number); if ($log < 0) { return 1; } else { return floor($log) + 1; } }
function get_max($numbers) { $max = max($numbers); if ($max < 1) { return $max; } $base = pow(10, floor(log10($max))); return ceil($max / $base) * $base; }
function semi_log($nb_modules) { global $pdf; global $nb_papier; global $width; global $tick; global $couleur_rgb_prim; global $couleur_rgb_sec; for ($page = 1; $page <= $nb_papier; $page++) { $pdf->AddPage(); // Grille secondaire $pdf->SetLineWidth($width["normal"]); $pdf->SetDrawColor($couleur_rgb_sec[0], $couleur_rgb_sec[1], $couleur_rgb_sec[2]); // Lignes verticales secondaires for ($j = 10; $j <= 200; $j++) { $pdf->Line($j, 10 - $tick["small"], $j, 280 + $tick["small"]); } $pdf->SetLineWidth($width["normal-bold"]); for ($j = 10; $j <= 200; $j += 10) { $pdf->Line($j, 10 - $tick["big"], $j, 280 + $tick["big"]); } // Lignes horizontales secondaires $pdf->SetLineWidth($width["normal"]); for ($i = 1; $i <= 10; $i += 0.1) { $y = 270 / $nb_modules - log10($i) * 270 / $nb_modules; for ($module = 1; $module <= $nb_modules; $module++) { $pdf->Line(10 - $tick["small"], 10 + $y, 200 + $tick["small"], 10 + $y); $y += 270 / $nb_modules; } } $pdf->SetLineWidth($width["normal-bold"]); for ($i = 1; $i <= 10; $i += 0.5) { $x = 270 / $nb_modules - log10($i) * 270 / $nb_modules; for ($module = 1; $module <= $nb_modules; $module++) { $pdf->Line(10 - $tick["big"], 10 + $x, 200 + $tick["big"], 10 + $x); $y += 270 / $nb_modules; } } // Grille primaire $pdf->SetLineWidth($width["bold"]); $pdf->SetDrawColor($couleur_rgb_prim[0], $couleur_rgb_prim[1], $couleur_rgb_prim[2]); for ($i = 1; $i <= 10; $i++) { $y = 270 / $nb_modules - log10($i) * 270 / $nb_modules; for ($module = 1; $module <= $nb_modules; $module++) { $pdf->Line(10 - $tick["verybig"], 10 + $y, 200 + $tick["verybig"], 10 + $y); $y += 270 / $nb_modules; } } for ($j = 10; $j <= 200; $j += 50) { $pdf->Line($j, 10 - $tick["verybig"], $j, 280 + $tick["verybig"]); } $pdf->Line(200, 10 - $tick["verybig"], 200, 280 + $tick["verybig"]); $type_papier = 'Papier semi-logarithmique à 1 module'; } $pdf->SetLineWidth($width["normal"]); }
/** * Rounding to significant digits (sort of like JavaScript's toPrecision()). * * @param float $number Value to round * @param integer $significantFigures Number of significant figures * * @return float */ public static function toPrecision($number, $significantFigures = 3) { if (0 === $number) { return 0; } $significantDecimals = floor($significantFigures - log10(abs($number))); $magnitude = pow(10, $significantDecimals); $shifted = round($number * $magnitude); return number_format($shifted / $magnitude, $significantDecimals); }
function AutoScale(&$img, $min, $max, $dummy) { if ($min == 0) { $min = 1; } assert($max > 0); $smin = floor(log10($min)); $smax = ceil(log10($max)); $this->Update($img, $smin, $smax); }
public function decimalPlaces() { if ($this->subunitToUnit == 1) { return 0; } elseif ($this->subunitToUnit % 10 == 0) { return floor(log10($this->subunitToUnit)); } else { return floor(log10($this->subunitToUnit) + 1); } }