Hello,I writed this code for testing: Code: Pascal [Select][+][-] var x: Int16; dc: string;begin x:= -20; dc := IntToHex(x, 2); ShowMessage(dc); end; printed result is 'FFFFFFEC',I would have expected a result like 'FFEC',where am I doing wrong?Thanks in advance.
A negative number is a large unsigned number which doesn't fit in the number of digits you specified (2). See Description.
Please note that the digits parameter is the minimum number of digits (as mentioned in the documentation you linked).
is used without truncation.
So I have to update the fpc to fix .... thanks a lot
Why so complicated? It is really easy (full program):Code: Pascal [Select][+][-]uses sysutils;var x: smallint; // use the proper Pascal syntax, int16 is an alias.begin x:= -20; writeln(x.ToHexString); // make use of the type helpers readln;end. Note 3.2.X or higher is required.Output is:Code: Bash [Select][+][-]FFECOvercomplicating things.......... (Note that I am responsible for the oversimplication)