Exemplo n.º 1
0
/* scales the input vector to the new length and returns it */
Vector3D *V3Scale(Vector3D *v, FixedPoint newlen) {
    FixedPoint len;
    
    len = V3Length(v);
    
    if (len != 0.0) {
	v->x = mulDiv(v->x,newlen,len);
	v->y = mulDiv(v->y,newlen,len);
	v->z = mulDiv(v->z,newlen,len);
    }
    return(v);
}
Exemplo n.º 2
0
bool plmin(const char *&ch)
{
    if (!mulDiv(ch))
        return false;
	while ((*ch == '+') || (*ch == '-'))
    {
        ch++;
		if ((*ch == '+') || (*ch == '-'))
			return false;
        if (!mulDiv(ch))
            return false;
    }
	return true;
}
Exemplo n.º 3
0
std::uint64_t
FeeMetrics::scaleFeeLevel(OpenView const& view) const
{
    auto fee = baseLevel;

    // Transactions in the open ledger so far
    auto const current = view.txCount();

    std::size_t target;
    std::uint32_t multiplier;
    {
        std::lock_guard <std::mutex> sl(lock_);

        // Target number of transactions allowed
        target = txnsExpected_;
        multiplier = escalationMultiplier_;
    }

    // Once the open ledger bypasses the target,
    // escalate the fee quickly.
    if (current > target)
    {
        // Compute escalated fee level
        // Don't care about the overflow flag
        fee = mulDiv(fee, current * current *
            multiplier, target * target).second;
    }

    return fee;
}