[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: How to configure konqueror to show KB and MB instead of KiB and
From:       Alan Alpert <alanalpert () optusnet ! com ! au>
Date:       2009-07-02 10:56:26
Message-ID: 200907022056.26362.alanalpert () optusnet ! com ! au
[Download RAW message or body]

There is a definitive standard here: http://xkcd.com/394/ which we could 
consider using (but not seriously). Might lighten up the discussion though.

On Thursday 02 July 2009 03:11:15 David Nadlinger wrote:
> I am definitely in favour of "just getting the option" – imho there is
> no other reasonable solution to this problem, given that it is not
> very likely that we will agree on either option in the near future. I
> would suggest offering "MiB", "MB (SI)", and "MB (traditional)" along
> with a manual entry which gives a brief overview about the topic.

I agree, as this makes it clear that MB (traditional computer usage) is not MB 
(SI), they are just homonyms. The SI prefixes are far more well known than the 
computer ones and it is very precise and exact. Anyone who knows it (and in 
the educational system I grew up in, that's everyone who didn't deliberately 
forget high school) will recognize that M means 10^9 (and may know that B 
means some computer science-y unit that's to do with size). While I agree that 
people should have the choice, since there seem to be people who really want 
it, it needs to be explained very clearly so as to remove confusion. And it 
should not default to MB = 2^20 ; just because the other desktop environments 
mentioned are okay with misleading their users doesn't mean it's right for us 
to do so (and it's not misleading if it's explained to users and they click 
that they understand). And I think from the emotions this subject brings up 
the phrasing of that manual entry may need a neutral third party.

> Personally, I really don't see the point in using the same unit symbol
> (KB) for two different units. If I was to find a universally used
> definition, I would propose using kB, MB, GB (note the lower case "k")
> for the power-of-ten units and KiB, MiB, GiB for the power-of-two
> units. But I suppose this will stay a vision, at least for the next
> several years... ;)

That is exactly what I was taught at university. Then they went on to say that 
they'd just always use kB, MB, GB since that was "done in practice". In 
practice it meant that every time they used the unit they had to put 10^9 or 
2^20 alongside anyway, making the units useless. In casual language 
imprecision due to common usage is fine. In the sciences it is not. This is 
computer science, no matter how many end users will see it too. And these are 
the same users that just shrug off losing 7.4% of their hard disk capacity... 
so I don't think they'll be that upset.



Anyway, attached is half the patch I'd like to see. It allows choice between 
kB and KiB (add "SIBytes=true" under [Locale] to 
$KDEHOME/share/config/kdeglobals to get kB instead of KiB). If I've convinced 
everyone that it's all we need, then we're set. More likely, you can combine 
it with the previous patch on this thread and you have all three options 
available for the people who want them. Note that this patch deliberately 
doesn't include adding the options to a configuration screen - I get the 
impression that we want this option hidden from users and it's just for 
distributors. Not to mention that it may be difficult to agree on how it's 
positioned to users. It probably belies the severity of this issue that 
writing and testing the patch took less time than writing the email.

One final thing the patch brought up... the section of code refers to bug 
#57240. I didn't read all of the comments because it appears to be a re-hash 
of this exact thread. My conclusion is that the comments in the code referred 
to maybe implementing the two checkbox system near the end of the comments on 
the bug (around comment 60 of 70) which no-one seemed to like. I've thus 
shortened that down to just the reference to the bug number since it seemed to 
be about the same issue. If I got that wrong due to skimming the bug comments 
then that's in error - tell me and I'll read through bug #57240 properly and 
act accordingly, as I really think that comment would need to go away if we 
add SI prefix support.

-- 
Alan Alpert

["siUnits.patch" (text/x-patch)]

Index: kdecore/localization/klocale.cpp
===================================================================
--- kdecore/localization/klocale.cpp	(revision 988411)
+++ kdecore/localization/klocale.cpp	(working copy)
@@ -229,6 +229,9 @@
   int weekDayOfPray;
   KLocale::DigitSet dateTimeDigitSet;
 
+  // Digital Size Units
+  bool siBytes; // to use kB, MB..., instead of KiB, MiB...
+
   // FIXME: Temporary until full language-sensitivity implemented.
   bool languageSensitiveDigits;
 
@@ -443,6 +446,8 @@
   readConfigEntry("PositiveSign", "", positiveSign);
   readConfigEntry("NegativeSign", "-", negativeSign);
 
+  readConfigEntry("SIBytes", false, siBytes);
+
   readConfigNumEntry("DigitSet", KLocale::ArabicDigits,
                      digitSet, KLocale::DigitSet);
   // FIXME: Temporary until full language-sensitivity implemented.
@@ -1340,52 +1345,75 @@
   return mantString + expString;
 }
 
-// If someone wants the SI-standard prefixes kB/MB/GB/TB, I would recommend
-// a hidden kconfig option and getting the code from #57240 into the same
-// method, so that all KDE apps use the same unit, instead of letting each app decide.
-
 QString KLocale::formatByteSize( double size ) const
 {
-    // Per IEC 60027-2
 
-    // Binary prefixes
+    // Binary prefixes Per IEC 60027-2
     //Tebi-byte             TiB             2^40    1,099,511,627,776 bytes
     //Gibi-byte             GiB             2^30    1,073,741,824 bytes
     //Mebi-byte             MiB             2^20    1,048,576 bytes
     //Kibi-byte             KiB             2^10    1,024 bytes
 
+    // SI prefixes
+    // Terabyte             TB              10^12   1,000,000,000,000 bytes
+    // Gigabyte             GB              10^9    1,000,000,000 bytes
+    // Megabyte             MB              10^6    1,000,000 bytes
+    // Kilobyte             kB              10^3    1,000 bytes
+
+    // Note that SI vs. IEC is covered in bug #57240
     QString s;
-    // Gibi-byte
-    if ( size >= 1073741824.0 )
-    {
-        size /= 1073741824.0;
-        if ( size > 1024 ) // Tebi-byte
-            s = i18n( "%1 TiB", formatNumber(size / 1024.0, 1));
+
+    if (d->siBytes) {//SI unit prefixes
+        double T = 1000000000000.0;
+        double G = 1000000000.0;
+        double M = 1000000.0;
+        double k = 1000.0;
+        if ( size >= T ) {
+            s = i18n( "%1 TB", formatNumber(size/T, 1));
+        } else if (size >= G ) {
+            s = i18n( "%1 GB", formatNumber(size/G, 1));
+        } else if (size >= M ) {
+            s = i18n( "%1 MB", formatNumber(size/M, 1));
+        } else if (size >= k ) {
+            s = i18n( "%1 kB", formatNumber(size/k, 1));
+        } else if (size > 0){ //B
+            s = i18n( "%1 B", formatNumber(size, 0));
+        } else {
+            s = i18n( "0 B" );
+        }
+    }else{//IEC 60027-2 prefixes
+        // Gibi-byte
+        if ( size >= 1073741824.0 )
+        {
+            size /= 1073741824.0;
+            if ( size > 1024 ) // Tebi-byte
+                s = i18n( "%1 TiB", formatNumber(size / 1024.0, 1));
+            else
+                s = i18n( "%1 GiB", formatNumber(size, 1));
+        }
+        // Mebi-byte
+        else if ( size >= 1048576.0 )
+        {
+            size /= 1048576.0;
+            s = i18n( "%1 MiB", formatNumber(size, 1));
+        }
+        // Kibi-byte
+        else if ( size >= 1024.0 )
+        {
+            size /= 1024.0;
+            s = i18n( "%1 KiB", formatNumber(size, 1));
+        }
+        // Just byte
+        else if ( size > 0 )
+        {
+            s = i18n( "%1 B", formatNumber(size, 0));
+        }
+        // Nothing
         else
-            s = i18n( "%1 GiB", formatNumber(size, 1));
+        {
+            s = i18n( "0 B" );
+        }
     }
-    // Mebi-byte
-    else if ( size >= 1048576.0 )
-    {
-        size /= 1048576.0;
-        s = i18n( "%1 MiB", formatNumber(size, 1));
-    }
-    // Kibi-byte
-    else if ( size >= 1024.0 )
-    {
-        size /= 1024.0;
-        s = i18n( "%1 KiB", formatNumber(size, 1));
-    }
-    // Just byte
-    else if ( size > 0 )
-    {
-        s = i18n( "%1 B", formatNumber(size, 0));
-    }
-    // Nothing
-    else
-    {
-        s = i18n( "0 B" );
-    }
     return s;
 }
 


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic