2
votes

I have a dll routine that returns a UInt32. I gather that the Delphi cardinal type is equivalent to this type. I'd like to display the UInt32 value as a string. However inttostr () assumes the argument is a signed Int32 so it will sometimes return a string that has the appearance of a negative value. Is there a way to convert a cardinal into its unsigned string representation?

Using XE6.

1
Is there not UintToStr?LU RD
Which Delphi are you using?SilverWarior
Didn't spot uinttostr, and I've been looking...and it worked.rhody
Good, you can make that an answer.LU RD
IntToStr() has an Int64 version, not just an Integer version. Also, Delphi 2009 and later have an actual UInt32 type, you should use that instead of Cardinal.Remy Lebeau

1 Answers

8
votes

To convert a UInt32 integer type into the unsigned string equivalent use the method UIntToStr.

For example:

value : UInt32;

value := 4294967294;
str := UIntToStr (value);
// str now equals '4294967294'