本文整理汇总了C++中Quantity::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ Quantity::setScale方法的具体用法?C++ Quantity::setScale怎么用?C++ Quantity::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quantity
的用法示例。
在下文中一共展示了Quantity::setScale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: push_back
void OSQuantityVector::push_back(Quantity q) {
if (!(q.units() == units())) {
LOG_AND_THROW("Quantity " << q << " is incompatible with this OSQuantityVector, which has "
"units " << units() << ".");
}
else if (q.scale() != scale()) {
q.setScale(scale().exponent);
}
m_values.push_back(q.value());
}
示例2: scale
OSQuantityVector::OSQuantityVector(const std::vector<Quantity>& values)
: m_units(), m_values(values.size(),0.0)
{
if (!values.empty()) {
m_units = values[0].units();
}
const Scale& myScale = scale();
for (unsigned i = 0, n = size(); i < n; ++i) {
if (!(values[i].units() == m_units)) {
LOG_AND_THROW("Quantity " << values[i] << " has units inconsistent with the first "
<< "Quantity in vector values, " << values[0] << ".");
}
if (values[i].scale() != myScale) {
Quantity working = values[i];
working.setScale(myScale.exponent);
m_values[i] = working.value();
}
else {
m_values[i] = values[i].value();
}
}
}