Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Xe10 issue OSX 16bit integers, smallint is 32 bits, and int16 doesn't work?


This question is answered.


Permlink Replies: 3 - Last Post: Dec 15, 2015 9:15 AM Last Post By: ray white
ray white

Posts: 7
Registered: 8/16/98
Xe10 issue OSX 16bit integers, smallint is 32 bits, and int16 doesn't work?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 11, 2015 12:23 PM
Hi in the documentation it says that smallint is a platform independent 16 bit integer, but when I do a sizeof it says 32 bits. The problem with that is I have old data files that have 16 bit integers in them.
I tried using int16 but I can't figure out what to do with that. In OSX delphi says it's not an ordinal type and it won't let me assign it to an integer variable.

Is there a conversion function I can use? How do I handle this?

Edited by: ray white on Dec 11, 2015 12:23 PM
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Xe10 issue OSX 16bit integers, smallint is 32 bits, and int16 doesn't work? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 11, 2015 1:14 PM   in response to: ray white in response to: ray white
Am 11.12.2015 um 21:23 schrieb ray white:
Hi in the documentation it says that smallint is a platform independent 16 bit integer, but when I do a sizeof it says 32 bits. The problem with that is I have old data files that have 16 bit integers in them.
I tried using int16 but I can't figure out what to do with that. In OSX delphi says it's not an ordinal type and it won't let me assign it to an integer variable.

Is there a conversion function I can use? How do I handle this?

Edited by: ray white on Dec 11, 2015 12:23 PM

Can you try a type cast at the line where you want to assign it?

e.g.

var
i : Integer;
i16: Int16;

begin
i16 := 123;
i := Integer(i16);
end;

Greetings

Markus
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Xe10 issue OSX 16bit integers, smallint is 32 bits, and int16 doesn'twork? [Edit]
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 11, 2015 1:46 PM   in response to: ray white in response to: ray white
ray wrote:

Hi in the documentation it says that smallint is a platform
independent 16 bit integer, but when I do a sizeof it says 32 bits.

Then you must not be using Delphi's Smallint type. Maybe your code is pulling
in a third-party unit/package that defines its own Smallint type?

I tried using int16 but I can't figure out what to do with that. In
OSX delphi says it's not an ordinal type and it won't let me assign
it to an integer variable.

Int16 is defined in the System unit for all platforms (and has been since
D2009):

type
  ...
  Int16   = SmallInt;
  ...


--
Remy Lebeau (TeamB)
ray white

Posts: 7
Registered: 8/16/98
Re: Xe10 issue OSX 16bit integers, smallint is 32 bits, and int16 doesn'twork? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 15, 2015 9:15 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
You were right. It was another unit. Thanks.

Remy Lebeau (TeamB) wrote:
ray wrote:

Hi in the documentation it says that smallint is a platform
independent 16 bit integer, but when I do a sizeof it says 32 bits.

Then you must not be using Delphi's Smallint type. Maybe your code is pulling
in a third-party unit/package that defines its own Smallint type?

I tried using int16 but I can't figure out what to do with that. In
OSX delphi says it's not an ordinal type and it won't let me assign
it to an integer variable.

Int16 is defined in the System unit for all platforms (and has been since
D2009):

type
  ...
  Int16   = SmallInt;
  ...


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02