INTTOHEX (10-16) Conversion)

xiaoxiao2021-03-06  55

I am very happy to have a good way to make a simple way than I want, many friends have a good way to see a friend's blog, and I still wrote 10-16 conversion. Write wrong, huh, huh, now you will leave it in the Internet, he is required to write the conversion instead of using similar format ('integer% 0: D in HEX IS% 0: .8X', [value]); of course, There is a simple way we have to use a simple way, then introduce your own method var Hexarr: array [1..15] of string = ('1', '2', '3', '4', '5', '6 ',' 7 ',' 8 ',' 9 ',' A ',' B ',' C ',' D ',' E ',' F ');

Function INT2HEX (Value: Integer): String; Var ITEMP: INTEGER; I: Integer; Begin Result: = '; i: = 0; While i <4 Do Begin Case I of 0: Itemp: = Value Shr 24 and $ FF; 1: itemp: = value SHR 16 and $ ff; 2: itemp: = value shr 8 and $ ff; 3: itemp: = value and $ ff; end; if not boolean (itemp) Then Result: = Result '00' Else Begin Result: = Result Hexarr [Itemp Div 16]; Result: = Result Hexarr [ITEMP MOD 16]; End; Inc (i); End; End; Test: ShowMessage (INT2HEX (-1)) ; // Display fffffffffffffffffffffffffff); // Shows 7FFFFFF I hope everyone will have more opinions, personal feeling is quite simple, huh, huh, it is obviously what is going on every step

转载请注明原文地址:https://www.9cbs.com/read-82257.html

New Post(0)