mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/unit] Coding style
This commit is contained in:
committed by
Émilie Feral
parent
f01f91d000
commit
157d74c0da
@@ -55,22 +55,23 @@ int UnitNode::Representative::serialize(char * buffer, int bufferSize, const Pre
|
||||
}
|
||||
|
||||
const UnitNode::Prefix * UnitNode::Representative::bestPrefixForValue(double & value, const int exponent) const {
|
||||
const Prefix * bestPre = &Unit::EmptyPrefix;
|
||||
if (isPrefixable()) {
|
||||
unsigned int diff = -1;
|
||||
/* Find the 'Prefix' with the most adequate 'exponent' for the order of
|
||||
* magnitude of 'value'.
|
||||
*/
|
||||
const int orderOfMagnitude = IEEE754<double>::exponentBase10(std::fabs(value));
|
||||
for (const Prefix * pre = m_outputPrefixes; pre < m_outputPrefixesUpperBound; pre++) {
|
||||
unsigned int newDiff = absInt(orderOfMagnitude - pre->exponent() * exponent);
|
||||
if (newDiff < diff) {
|
||||
diff = newDiff;
|
||||
bestPre = pre;
|
||||
}
|
||||
}
|
||||
value *= std::pow(10.0, -bestPre->exponent() * exponent);
|
||||
if (!isPrefixable()) {
|
||||
return &Unit::EmptyPrefix;
|
||||
}
|
||||
const Prefix * bestPre = nullptr;
|
||||
unsigned int diff = -1;
|
||||
/* Find the 'Prefix' with the most adequate 'exponent' for the order of
|
||||
* magnitude of 'value'.
|
||||
*/
|
||||
const int orderOfMagnitude = IEEE754<double>::exponentBase10(std::fabs(value));
|
||||
for (const Prefix * pre = m_outputPrefixes; pre < m_outputPrefixesUpperBound; pre++) {
|
||||
unsigned int newDiff = absInt(orderOfMagnitude - pre->exponent() * exponent);
|
||||
if (newDiff < diff) {
|
||||
diff = newDiff;
|
||||
bestPre = pre;
|
||||
}
|
||||
}
|
||||
value *= std::pow(10.0, -bestPre->exponent() * exponent);
|
||||
return bestPre;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user