global-functions: $GetRandomNumber: use $HexToNum

This commit is contained in:
Christian Hesse 2021-06-28 00:46:27 +02:00
parent cfc400b3d5
commit 679917390b

View file

@ -416,18 +416,9 @@
} }
:global GetRandom20CharHex; :global GetRandom20CharHex;
:global HexToNum;
:local Num; :return ([ $HexToNum [ :pick [ $GetRandom20CharHex ] 0 15 ] ] % $Max);
:local 40CharHex ([ $GetRandom20CharHex ] . [ $GetRandom20CharHex ]);
:for I from=0 to=39 do={
:local Char [ :pick $40CharHex $I ];
:if ($Char~"[0-9]") do={
:set Num ($Num . $Char);
}
}
:return ([ :tonum [ :pick $Num 0 18 ] ] % $Max);
} }
# convert from hex (string) to num # convert from hex (string) to num