Gets the mass-to-charge value for the specified mass and charge

@param float $mass
@param int $charge
@return float
422351
public static function getMassCharge($mass, $charge)
    {
        if (! is_float($mass)) {
            throw new \InvalidArgumentException('Argument 1 must be of type float. Value is of type ' . gettype($mass));
        }

        if (! is_int($charge)) {
            throw new \InvalidArgumentException('Argument 2 must be of type int. Value is of type ' . gettype($charge));
        }

        if ($charge == 0) {
            return $mass;
        }

        return ($mass + ($charge * PhysicalConstants::PROTON_MASS)) / $charge;
    }
666799
def calcMassFromMz(mz, charge):
    
    mass = (mz - maspy.constants.atomicMassProton) * charge
    return mass
1268436
def get_electron_number(self, charge=0):
        
        atomic_number = constants.elements['atomic_number'].to_dict()
        return sum([atomic_number[atom] for atom in self['atom']]) - charge
290468
public function getPartialSum( $from, $to )
	{
		for( $i=$from; $i<=$to; $i++ )
			$sum += $this->getValue( $i );
		return $sum;
	}
522461
public function getDaltonDelta($mass)
    {
        if ($this->unit == Tolerance::DA) {
            return $this->tolerance;
        }

        $toleranceRatio = $this->tolerance / 1000000;

        return $mass * $toleranceRatio;
    }
1092397
def calcMzFromMh(mh, charge):
    
    mz = (mh + (maspy.constants.atomicMassProton * (charge-1))) / charge
    return mz
142381
def charged(self, charge):
        
        result = self.copy()
        result.addCharge(charge)
        return result
281484
public function getBalanceTransactionReference()
    {
        if (isset($this->data['object']) && 'charge' === $this->data['object']) {
            return $this->data['balance_transaction'];
        }
        if (isset($this->data['object']) && 'balance_transaction' === $this->data['object']) {
            return $this->data['id'];
        }
        if (isset($this->data['error']) && isset($this->data['error']['charge'])) {
            return $this->data['error']['charge'];
        }

        return null;
    }
741223
public function get(?string $unit = null): int
    {
        if (null === $this->value) {
            $this->value = $this->stringToBytes(ini_get('upload_max_filesize'));
        }
        $value = $this->value;

        switch ($unit) {
            case self::GIGABYTES:
                $value /= 1024;
            case self::MEGABYTES:
                $value /= 1024;
            case self::KILOBYTES:
                $value /= 1024;
            case self::BYTES:
            default:
        }

        return $value;
    }
991324
public static function getRate($from, $to) {
    // Check if currencies exists
    if (!Connect2PayCurrencyHelper::currencyIsAvailable($from) || !Connect2PayCurrencyHelper::currencyIsAvailable($to)) {
      return null;
    }

    // Build the request URL
    $url = Connect2PayCurrencyHelper::$APIIO_SERVICE_URL . date("Y-m-d") . "?base=" . $from . "&symbols=" . $to;

    // Do the request
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

    if (Connect2PayCurrencyHelper::$proxy_host != null && Connect2PayCurrencyHelper::$proxy_port != null) {
      curl_setopt($curl, CURLOPT_PROXY, Connect2PayCurrencyHelper::$proxy_host);
      curl_setopt($curl, CURLOPT_PROXYPORT, Connect2PayCurrencyHelper::$proxy_port);

      if (Connect2PayCurrencyHelper::$proxy_username != null && Connect2PayCurrencyHelper::$proxy_password != null) {
        curl_setopt($curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
        curl_setopt($curl, CURLOPT_PROXYUSERPWD,
            Connect2PayCurrencyHelper::$proxy_username . ":" . Connect2PayCurrencyHelper::$proxy_password);
      }
    }

    $json = trim(curl_exec($curl));
    $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);

    if ($httpCode == 200) {
      // Parse the CSV, we should only have a number, check this
      $obj = json_decode($json, true);

      if (is_array($obj) && array_key_exists("rates", $obj) && array_key_exists($to, $obj['rates']) &&
          preg_match('/^[0-9.]+$/', $obj['rates'][$to])) {
        return $obj['rates'][$to];
      }
    }

    return null;
  }
1200351
public Charge create(Charge charge) throws BaseException {

		logger.debug("Enter ChargeService::create");
		
		// prepare API url
		String apiUrl = requestContext.getBaseUrl() + "charges".replaceAll("\\{format\\}", "json");
		logger.info("apiUrl - " + apiUrl);
		
		// assign TypeReference for deserialization
		TypeReference<Charge> typeReference = new TypeReference<Charge>() {
		};

		// prepare service request
		Request request = new Request.RequestBuilder(MethodType.POST, apiUrl).requestObject(charge)
				.typeReference(typeReference).context(requestContext).build();

		// make API call
		Response response = sendRequest(request);

		// retrieve response
		Charge chargeResponse = (Charge) response.getResponseObject();

		// set additional attributes
		prepareResponse(request, response, chargeResponse);
		return chargeResponse;
	}
964398
def total_charge(self):
        
        charge = (sum(self.data_points) / self.hz) * 1000 / 3600
        return round(charge, self.sr)
814420
protected function _calcPaymentCost()
    {
        // resetting values
        $oPaymentPrice = oxNew(\OxidEsales\Eshop\Core\Price::class);

        // payment
        if (($this->_sPaymentId = $this->getPaymentId())) {
            $oPayment = oxNew(\OxidEsales\Eshop\Application\Model\Payment::class);
            $oPayment->load($this->_sPaymentId);

            $oPayment->calculate($this);
            $oPaymentPrice = $oPayment->getPrice();
        }

        return $oPaymentPrice;
    }
790730
public function getTotalWeight()
    {
        $totalWeight = 0;

        if ($this->count()) {
            foreach ($this->storage as $id => $item) {
                if (isset($item[ 'subTotal' ][ 'weight' ])) {
                    $totalWeight += (int)$item[ 'weight' ];
                }
            }
        }

        return $totalWeight;
    }
415563
public function getTotalTaxAmount()
    {
        // Convert to minor units for more accurate calculations
        $total_amount = CurrencyUtils::amountToExponent($this->getTotalAmount(), $this->currency);
        $tax_rate     = CurrencyUtils::amountToExponent($this->tax_rate, $this->currency);

        $total_tax_amount = ceil(
            $total_amount - ( ($total_amount * 10000) / (10000 + $tax_rate) )
        );

        return CurrencyUtils::exponentToAmount($total_tax_amount, $this->currency);
    }
553016
private function chargeNew($capture) {return dfc($this, function($capture) {
		$fc = $this->fCharge(); /** @var fCharge $fc */
		/**
		 * 2017-06-11
		 * Some PSPs like Moip require 2 steps to make a payment:
		 * 1) Creating an «order».
		 * 2) Creating a «payment».
		 * To implement such a scheme, the @uses \Df\StripeClone\P\Charge::request()
		 * should return data for the both requests,
		 * and then @uses \Df\StripeClone\Facade\Charge::create() should make the both requests.
		 */
		/** @var array(string => mixed) $preorderParams */
		if ($needPreorder = $fc->needPreorder() /** @var bool $needPreorder */) {
			$preorderParams = pPreorder::request($this);
			df_sentry_extra($this, 'Preorder Params', $preorderParams);
			$fc->preorderSet(fPreorder::s($this)->create($preorderParams));
		}
		$p = pCharge::request($this, $capture); /** @var array(string => mixed) $p */
		df_sentry_extra($this, 'Request Params', $p);
		$result = $fc->create($p); /** @var object|array(string => mixed) $result */
		if ($this->isCard()) {
			/**
			 * 2017-07-24
			 * Unfortunately, the one-liner fails on PHP 5.6.30:
			 * $this->iiaAdd((CardFormatter::s($this, $fc->card($result)))->ii());
			 * «syntax error, unexpected '->' (T_OBJECT_OPERATOR)»
			 * https://github.com/mage2pro/core/issues/15
			 * See also: https://github.com/mage2pro/core/issues/16
			 *
			 * 2017-07-31
			 * Interestingly, the following code works on all PHP versions >= 5.4.0:
			 * class A {function f() {return __METHOD__;}
			 * echo (new A)->f();
			 * https://3v4l.org/nANqg
			 *
			 * The following code works on all PHP versions >= 5.0.0:
			 *	class A {
			 *		function f() {return __METHOD__;}
			 *		static function s() {return new self;}
			 *	}
			 *	echo A::s()->f();
			 * https://3v4l.org/1qr48
			 *
			 * The same is true for the following code:
			 *	class A {
			 *		function f() {return $this->_v;}
			 *		final protected function __construct($v) {$this->_v = $v;}
			 *		private $_v;
			 *		final static function s($v) {return new self($v);}
			 *	}
			 *	echo A::s('test')->f();
			 * https://3v4l.org/2E8H6
			 *
			 * So, I was unable to reproduce the issue...
			 * Maybe the problem customer uses a non-standard (patched) PHP version?
			 *
			 * 2017-11-08
			 * Note 1.
			 * One-liners like (!($e = $a->e())->b()) are really not supported by PHP < 7:
			 * https://3v4l.org/lJjvS
			 * Note 2.
			 * At the same time, some `))->` one-liners are supported by PHP >= 5.4, e.g:
			 * static function p() {return (new self())->b();}
			 * https://3v4l.org/LJlDE
			 * Note 3.   
			 * If we add extra brackets to the code from the Note 2,
			 * then the code will be incompatible with PHP < 7:
			 * static function p() {return ((new self()))->b();}
			 */
			$cf = CardFormatter::s($this, $fc->card($result)); /** @var CardFormatter $cf */
			$this->iiaAdd($cf->ii());
		}
		$this->transInfo($result, $p + (!$needPreorder ? [] : ['df_preorder' => $preorderParams]));
		$needRedirect = $this->redirectNeeded($result); /** @var bool $needRedirect */
		$i = $this->ii(); /** @var II|OP|QP $i */
		/**
		 * 2016-03-15
		 * Иначе операция «void» (отмена авторизации платежа) будет недоступна:
		 * «How is a payment authorization voiding implemented?»
		 * https://mage2.pro/t/938
		 * https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Sales/Model/Order/Payment.php#L540-L555
		 * @used-by \Magento\Sales\Model\Order\Payment::canVoid()
		 *
		 * 2016-12-16
		 * Раньше мы окончание не добавляли, и это приводило к проблеме https://mage2.pro/t/2381
		 * При Refund из интерфейса Stripe метод \Dfe\Stripe\Handler\Charge\Refunded::process()
		 * находил транзакцию типа «capture» путём добавления окончания «-capture»
		 * к идентификатору платежа в Stripe.
		 * Однако если у платежа не было стадии «authorize»,
		 * то в данной точке кода окончание «capture» не добавлялось,
		 * а вот поэтому Refund из интерфейса Stripe не работал.
		 */
		$i->setTransactionId($this->e2i($fc->id($result),
			$needRedirect ? $this->transPrefixForRedirectCase() :
				($capture ? Ev::T_CAPTURE : Ev::T_AUTHORIZE)
		));
		/**
		 * 2016-03-15
		 * Если оставить открытой транзакцию «capture»,
		 * то операция «void» (отмена авторизации платежа) будет недоступна:
		 * https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Sales/Model/Order/Payment.php#L540-L555
		 * @used-by \Magento\Sales\Model\Order\Payment::canVoid()
		 * Транзакция считается закрытой, если явно не указать «false».
		 *
		 * 2017-01-16
		 * Наоборот: если закрыть транзакцию типа «authorize»,
		 * то операция «Capture Online» из административного интерфейса будет недоступна:
		 * @see \Magento\Sales\Model\Order\Payment::canCapture()
		 *		if ($authTransaction && $authTransaction->getIsClosed()) {
		 *			$orderTransaction = $this->transactionRepository->getByTransactionType(
		 *				Transaction::TYPE_ORDER,
		 *				$this->getId(),
		 *				$this->getOrder()->getId()
		 *			);
		 *			if (!$orderTransaction) {
		 *				return false;
		 *			}
		 *		}
		 * https://github.com/magento/magento2/blob/2.1.3/app/code/Magento/Sales/Model/Order/Payment.php#L263-L281
		 * «How is \Magento\Sales\Model\Order\Payment::canCapture() implemented and used?»
		 * https://mage2.pro/t/650
		 * «How does Magento 2 decide whether to show the «Capture Online» dropdown
		 * on a backend's invoice screen?»: https://mage2.pro/t/2475
		 */
		$i->setIsTransactionClosed($capture && !$needRedirect);
		if ($needRedirect) {
			/**
			 * 2016-07-10
			 * @uses \Magento\Sales\Model\Order\Payment\Transaction::TYPE_PAYMENT —
			 * это единственный транзакция без специального назначения,
			 * и поэтому мы можем безопасно его использовать
			 * для сохранения информации о нашем запросе к платёжной системе.
			 * 2017-01-12
			 * Сделал по аналогии с @see \Df\PaypalClone\Method::addTransaction()
			 * Иначе транзакция не будет записана.
			 * Что интересно, если првоерка 3D Secure не нужна,
			 * то и этой специальной операции записи транзакции не нужно:
			 * она будет записана автоматически.
			 */
			$i->addTransaction(T::TYPE_PAYMENT);
		}
		return $result;
	}, func_get_args());}
941363
@Override
	public ChargeInfo getChargeInfo(String CorpNum, int ItemCode) throws PopbillException{
		return httpget("/Statement/ChargeInfo/" + Integer.toString(ItemCode), CorpNum, null, ChargeInfo.class);
	}