aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-04-07 21:11:03 +0200
committerGravatar Christian Hesse <mail@eworm.de>2024-04-07 22:51:24 +0200
commit3015743b19883d2e19605b819fd2bbcbc6597d8f (patch)
tree2025d825b6afdfafcda11bd95c90bc361eb24d29 /global-functions.rsc
parent36cf4d028bcf9597143249aed238dc5e131fda50 (diff)
global-functions: $HumanReadableNum: indicate binary base...
... and update scripts to match the change.
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);
}
}
}