Вход Регистрация
Файл: vendor/brick/math/src/Internal/Calculator/BcMathCalculator.php
Строк: 90
<?php

declare(strict_types=1);

namespace 
BrickMathInternalCalculator;

use 
BrickMathInternalCalculator;

/**
 * Calculator implementation built around the bcmath library.
 *
 * @internal
 *
 * @psalm-immutable
 */
class BcMathCalculator extends Calculator
{
    
/**
     * {@inheritdoc}
     */
    
public function add(string $astring $b) : string
    
{
        return 
bcadd($a$b0);
    }

    
/**
     * {@inheritdoc}
     */
    
public function sub(string $astring $b) : string
    
{
        return 
bcsub($a$b0);
    }

    
/**
     * {@inheritdoc}
     */
    
public function mul(string $astring $b) : string
    
{
        return 
bcmul($a$b0);
    }

    
/**
     * {@inheritdoc}
     *
     * @psalm-suppress InvalidNullableReturnType
     * @psalm-suppress NullableReturnStatement
     */
    
public function divQ(string $astring $b) : string
    
{
        return 
bcdiv($a$b0);
    }

    
/**
     * {@inheritdoc}
     *
     * @psalm-suppress InvalidNullableReturnType
     * @psalm-suppress NullableReturnStatement
     */
    
public function divR(string $astring $b) : string
    
{
        if (
version_compare(PHP_VERSION'7.2') >= 0) {
            return 
bcmod($a$b0);
        }

        return 
bcmod($a$b);
    }

    
/**
     * {@inheritdoc}
     */
    
public function divQR(string $astring $b) : array
    {
        
$q bcdiv($a$b0);

        if (
version_compare(PHP_VERSION'7.2') >= 0) {
            
$r bcmod($a$b0);
        } else {
            
$r bcmod($a$b);
        }

        
assert($q !== null);
        
assert($r !== null);

        return [
$q$r];
    }

    
/**
     * {@inheritdoc}
     */
    
public function pow(string $aint $e) : string
    
{
        return 
bcpow($a, (string) $e0);
    }

    
/**
     * {@inheritdoc}
     */
    
public function modPow(string $basestring $expstring $mod) : string
    
{
        return 
bcpowmod($base$exp$mod0);
    }

    
/**
     * {@inheritDoc}
     */
    
public function sqrt(string $n) : string
    
{
        return 
bcsqrt($n0);
    }
}
Онлайн: 0
Реклама