Link to home
Start Free TrialLog in
Avatar of mac_rowe
mac_rowe

asked on

My Cardinal is signed !

According to the Delphi 3 Help file, cardinals are meant to be a 32 bit unsigned number.

However it is definately a 32 bit signed number on my system. (WinNT)

Try typing '(cardinal($7FFFFFFF)+1)' in the 'evaluate/modify' window and you will get a range check error instead of the correct answer of $80000000.

Also Cardinal($FFFFFFFF) gives '-1'.

Q1. Is this unique to me or does everyone else have the same issue?

Q2. So how do I get a 32 bit unsigned number?  (Simply printing it out differently at the end doesn't help, because the maths in the middle should be correct to)

(For example: $8000 0000 / 2 = ??
  Signed:   $C000 0000
  Unsigned: $4000 0000)

ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Madshi
Madshi

Ray is right. D3 has no 32bit unsigned support at all. Perhaps you can use the type "comp". Not very handy though.
In D4 Borland introduced "real" 32bit unsigned support with cardinal = longWord = 32bit unsigned.

Regards, Madshi.
P.S: You should seriously think about upgrading to D4 or D5, because there are tons of other quite important language extensions like int64 (real 64bit integer type), predefined parameters, function/method overloading and more...
Avatar of mac_rowe

ASKER

Hmm, so the Delphi documentation is a lie.  Didn't someone notice this before they released it ?

Ironically I use D5 at home but here at work we are on good ol' fashioned D3.  When you have several licenses it is quite expensive to upgrade, so I'd like to stick to D3 for the moment, rather than force the entire company to upgrade.

I've found so far the best solution is to turn range checking off and simply pretend that it is unsigned.  It is pretty good apart from the division problem mentioned earlier.

I'll check out a couple of possibilities...

Yes, you get a 'excellent' grade for proving to me that I wasn't mad after all.

Your welcome!

Cheers,

Raymond.