string nice_unit_format(
const int64_t input,
- const UnitBase system,
- const UnitFormat symbolformat
+ const UnitBase base,
+ const UnitFormat format
)
{
// select the system of units (decimal or binary)
int multiple = 0;
- if (system == UnitBase1000)
+ if (base == UnitBase1000)
{
multiple = 1000;
}
sizecount++;
}
- // round the input number
+ // round the input number "half up" to multiples of 10
+ const int rounding_multiplier = 10;
long double tmp;
- tmp = size * 10;
+ tmp = size * rounding_multiplier;
tmp += 0.5;
tmp = (int64_t) (tmp);
- tmp = (long double) (tmp) / (long double) (10);
+ tmp = (long double) (tmp) / (long double) (rounding_multiplier);
size = tmp;
// format the input number, placing the appropriate symbol
ostringstream out;
out.setf (ios::fixed);
- if (symbolformat == ShortUnitFormat)
+ if (format == ShortUnitFormat)
{
out.precision(1);
out << size << i18n( symbolFormatShort[sizecount].c_str() );
std::string nice_unit_format(
const int64_t input,
- const UnitBase system = UnitBase1000,
- const UnitFormat symbolformat = LongUnitFormat
+ const UnitBase base = UnitBase1000,
+ const UnitFormat format = LongUnitFormat
);
bool replace_all(std::string &base, const std::string *ist, const std::string *soll);