# Board index » delphi » Unsigned Long Integers?????

## Unsigned Long Integers?????

I know that there is no unsigned long integer in Pascal(Delphi), but is
there an easy way around it?

I have some routines in C which I would like to convert to a Delphi
component, instead of using a DLL.  These routines make a lot of use
of unsigned Long integers.

Currently I am doing the following, is there an easier way?

Type
ULONG32 = record
LoWord16: WORD;
HiWord16: WORD;
end;

PULONG32 = ^ULONG32

var
Low16: LongInt;
Hi16: WORD;

begin
Low16 := L1^.LoWord16;
Inc(Low16, L2^.LoWord16);
Hi16 := L1^.HiWord16 + L2^.HiWord16 + (Low16 SHR 16);
{Low16 SHR 16 handles the carry from lower 16bits}
Result.LoWord16 := WORD(Low16);
Result.HiWord16 := Hi16;

Any help would be appreciated.
Thanks.
------
Greg Carter, Electrical Engineer
email gr...@cryptocard.com

## Re:Unsigned Long Integers?????

If you really need DWORD's there's no easier way. You can simply
use longints instead unless there are values larger than 2^31 involved.
(Seems like most in most situations where numbers larger than 2^31 come
up there will also be numbers larger than 2^32 so DWORD's won't work
either. So what the heck...)

--
David Ullrich
Don't you guys find it tedious typing the same thing
after your signature each time you post something?
I know I do, but when in Rome...

## Re:Unsigned Long Integers?????

##### Quote
gr...@cryptocard.com (Greg Carter) wrote:

>I know that there is no unsigned long integer in Pascal(Delphi), but is
>there an easy way around it?

Your solution is not bad. Another way to do it is simply use longint and
offset all the values by -2147483647. So 0 becomes -2147483647,
2147483647 becomes 0, and 2147483647*2 becomes 2147483647.
In other words, shift the 0..2147483647*2 range to
-2147483647..+2147483647. I am not sure if this will work for your
problem.

## Re:Unsigned Long Integers?????

##### Quote
Greg Carter (gr...@cryptocard.com) wrote:

: I know that there is no unsigned long integer in Pascal(Delphi), but is
: there an easy way around it?

The single best way is to use Delphi32, out soon.  :)

I still can't believe they don't have a 32-bit unsigned integer in
Delphi.  It's really silly, and I guess the workaround you proposed is

Steve Neumann
sneum...@owlnet.rice.edu

## Re:Unsigned Long Integers?????

##### Quote
>: I know that there is no unsigned long integer in Pascal(Delphi), but is
>: there an easy way around it?

Around what? (What is it you want to do? For most purposes a long
works just as well...)

--
David Ullrich
Don't you guys find it tedious typing the same thing
after your signature each time you post something?
I know I do, but when in Rome...