Re: shorts and longs
- From: "Lance" <nunya@xxxxxxxxxxxx>
- Date: Tue, 26 Jul 2005 12:09:14 -0500
thanks for the explanation, bob. i think in my case i can accept the value as a long
instead of an integer.
"Bob Butler" <tiredofit@xxxxxxxxxx> wrote in message
news:eYQKjCgkFHA.3968@xxxxxxxxxxxxxxxxxxxxxxx
> "Lance" <nunya@xxxxxxxxxxxx> wrote in message
> news:ejvfy8fkFHA.2916@xxxxxxxxxxxxxxxxxxxx
>> it was my understanding that a c type short was equal to a vb type
>> integer, and a c type long was equal to a vb type long.
>
> ...c type "int" is the same as a VB type long
>
>> according to the tif file specs, the compression tag (259) stores
>> it's value (either 1, 2, 3, 4, 5, 6, or 32773) as a short type (a vb
>> integer) but as you can see, one of the valid values of the
>> compression type is 32773, which is out of the range of a vb integer.
>> so, when i Dim m_Compression as Integer and the return value is
>> 32773, i get an overflow obviously. i can change it to Dim
>> m_Compression as Long, but will that cause any trouble i'm not aware
>> of?
>
> 32773 is valid for an unsigned 16-bit value; it is not valid for a signed
> 16-bit value and unfortunately VB only supports signed values. If you read
> the 16-bit value from a file into an Integer variable you will get a
> negative number (-32763) which is fine since it will have the same bit
> pattern as +32773 so it is essentially equivalent. If you are calling a
> function that returns a 16-bit value then it should also work but if you
> call a function that returns a 32-bit value then VB will complain about not
> being able to convert to Integer because it will be outside the range. You
> can accept that value into a VB Long to avoid the error and then mask off
> the lower 16 bits but how you handle it will depend on what the exact
> situation is. What are you calling that is giving you the return value and
> how is that function defined?
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>
.
- References:
- shorts and longs
- From: Lance
- Re: shorts and longs
- From: Bob Butler
- shorts and longs
- Prev by Date: Re: shorts and longs
- Next by Date: Re: shorts and longs
- Previous by thread: Re: shorts and longs
- Next by thread: Re: shorts and longs
- Index(es):
Relevant Pages
|