aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions.rsc
diff options
context:
space:
mode:
Diffstat (limited to 'global-functions.rsc')
-rw-r--r--global-functions.rsc8
1 files changed, 6 insertions, 2 deletions
diff --git a/global-functions.rsc b/global-functions.rsc
index c8fec8d..aa39118 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -578,11 +578,13 @@
:local Base [ :tonum $2 ];
:global EitherOr;
+ :global IfThenElse;
:local Prefix "kMGTPE";
:local Pow 1;
:set Base [ $EitherOr $Base 1024 ];
+ :local Bin [ $IfThenElse ($Base = 1024) "i" "" ];
:if ($Input < $Base) do={
:return $Input;
@@ -595,9 +597,11 @@
:local Tmp1 ($Input * 100 / $Pow);
:local Tmp2 ($Tmp1 / 100);
:if ($Tmp2 >= 100) do={
- :return ($Tmp2 . $Prefix);
+ :return ($Tmp2 . $Prefix . $Bin);
}
- :return ($Tmp2 . "." . [ :pick $Tmp1 [ :len $Tmp2 ] ([ :len $Tmp1 ] - [ :len $Tmp2 ] + 1) ] . $Prefix);
+ :return ($Tmp2 . "." . \
+ [ :pick $Tmp1 [ :len $Tmp2 ] ([ :len $Tmp1 ] - [ :len $Tmp2 ] + 1) ] . \
+ $Prefix . $Bin);
}
}
}