--- a/UnitConverter.st Mon Jun 22 16:35:24 2015 +0200
+++ b/UnitConverter.st Mon Jun 22 16:38:28 2015 +0200
@@ -825,7 +825,7 @@
unitStringFor:nBytes
scale:1024
rounded:true
- unitStrings:#(' Byte' ' KiB' ' MiB' ' GiB' ' TiB' ' PiB' ' EiB' ' ZiB' ' YiB')
+ unitStrings:#('Byte' 'KiB' 'MiB' 'GiB' 'TiB' 'PiB' 'EiB' 'ZiB' 'YiB')
"/ the one below was written to save divisions.
"/ It seems to be not worth the effort...
@@ -986,7 +986,7 @@
unitStringFor:nBytes
scale:1000
rounded:true
- unitStrings:#(' Byte' ' KB' ' MB' ' GB' ' TB' ' PB' ' EB' ' ZB' ' YB')
+ unitStrings:#('Byte' 'KB' 'MB' 'GB' 'TB' 'PB' 'EB' 'ZB' 'YB')
"/ |unitString n|
"/
@@ -1209,7 +1209,7 @@
unitStringFor:hertz
scale:1000
rounded:false
- unitStrings:#(' Hz' ' Khz' ' Mhz' ' Ghz' ' Thz' ' Phz' ' Ehz')
+ unitStrings:#('Hz' 'Khz' 'Mhz' 'Ghz' 'Thz' 'Phz' 'Ehz')
"
self frequencyStringFor:10
@@ -1252,7 +1252,7 @@
Notice that both forms are often encountered and useful.
If rounded is true, round to nearest integer"
- |n kN idx val|
+ |n kN idx val unitString|
nBytes isNil ifTrue:[
^ '-'
@@ -1267,10 +1267,12 @@
].
val := nBytes / kN.
+ unitString := ' ',(unitStrings at:idx).
+
((rounded and:[val > 20]) or:[val isInteger]) ifTrue:[
- ^ (val rounded) printString , (unitStrings at:idx)
+ ^ (val rounded) printString , unitString
].
- ^ (val asFixedPoint:1) printString , (unitStrings at:idx)
+ ^ (val asFixedPoint:1) printString , unitString
"
self fileSizeStringFor:nil