Quantcast
Channel: Silk Performer
Viewing all articles
Browse latest Browse all 4084

Wiki Page: How can I convert a decimal number to a hexadecimal number in BDL?

$
0
0
The following script shows one way to convert a decimal number to a hexadecimal number. It should correctly convert postive numbers between 0 and 2147483647. The script prints the hexadecimal value of a random decimal number and can be adapted as required. benchmark WebBenchmarkName use "WebAPI.bdh" dclrand rNum : RndUniN(100..6000); dclfunc // converts decimal numbers under 15 to their hex equivalent function fConvertNumToHex(i : number) : number begin       if i = 0 then         fConvertNumToHex:= ord('0');     elseif i = 1 then         fConvertNumToHex:= ord('1');     elseif i = 2 then         fConvertNumToHex:= ord('2');     elseif i = 3 then         fConvertNumToHex:= ord('3');     elseif i = 4 then         fConvertNumToHex:= ord('4');     elseif i = 5 then         fConvertNumToHex:= ord('5');     elseif i = 6 then         fConvertNumToHex:= ord('6');     elseif i = 7 then         fConvertNumToHex:= ord('7');     elseif i = 8 then         fConvertNumToHex:= ord('8');     elseif i = 9 then         fConvertNumToHex:= ord('9');     elseif i = 10 then         fConvertNumToHex:= ord('A');     elseif i = 11 then         fConvertNumToHex:= ord('B');     elseif i = 12 then         fConvertNumToHex:= ord('C');     elseif i = 13 then         fConvertNumToHex:= ord('D');     elseif i = 14 then         fConvertNumToHex:= ord('E');     elseif i = 15 then         fConvertNumToHex:= ord('F');     end;    end fConvertNumToHex; // converts decimal number to hex - requires function fConvertNumToHex function fConvert (i : number) : string var     count : number;     sTemp:string; begin     count := 0;     while (i 0) do         count := count + 1;         sTemp[count] := chr(fConvertNumToHex(i mod 16));         i := i / 16;     end;     fConvert := strRev(sTemp); end fConvert; Old KB# 19171

Viewing all articles
Browse latest Browse all 4084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>