From 3015743b19883d2e19605b819fd2bbcbc6597d8f Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Sun, 7 Apr 2024 21:11:03 +0200 Subject: global-functions: $HumanReadableNum: indicate binary base... ... and update scripts to match the change. --- global-functions.rsc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'global-functions.rsc') 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); } } } -- cgit v1.2.3-54-g00ecf