Rename variables according with their enumeration type names
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Wed, 2 Feb 2011 11:08:19 +0000 (12:08 +0100)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@intra2net.com>
Wed, 2 Feb 2011 11:08:19 +0000 (12:08 +0100)
src/stringfunc.cpp
src/stringfunc.hxx

index fc5ae60..310cb01 100644 (file)
@@ -921,13 +921,13 @@ const string symbolFormatLong[MAX_SYMBOL_FORMATS] = {
 
 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;
    }
@@ -946,18 +946,19 @@ string nice_unit_format(
        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() );
index ca45bd4..47fc607 100644 (file)
@@ -204,8 +204,8 @@ enum UnitFormat {
 
 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);