Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

how to represent int64 in VB?

How does one represent large numbers like the int64 (e.g. file times) in VB?
Thanks.
[93 byte] By [- John of Arc -] at [2007-11-10 0:19:17]
# 1 Re: how to represent int64 in VB?
John <snip>,

> How does one represent large numbers like the int64 (e.g. file times) in
VB?

The short answer is that VB doesn't support 64 bit integers.

You could probably come up with a way to represent them using a Byte or Long
array. For some tasks, using the Decimal data type of a variant might work.
It depends on what you need to do with that int64.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jonathan Wood at 2007-11-11 20:05:08 >
# 2 Re: how to represent int64 in VB?
John <snip>,

> How does one represent large numbers like the int64 (e.g. file times) in
VB?

The short answer is that VB doesn't support 64 bit integers.

You could probably come up with a way to represent them using a Byte or Long
array. For some tasks, using the Decimal data type of a variant might work.
It depends on what you need to do with that int64.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jonathan Wood at 2007-11-11 20:06:13 >
# 3 Re: how to represent int64 in VB?
If you are passing by reference pass the first long of a long array of two
elements eg

dim l(1 to 2) as long

call someroutine(l(1))

BUT don't forget the number will come back reversed

so if you had a value 1 in the 64 bit number hex H00000000 00000001

it will come back as

l(1) = H00000001
l(2) = H00000000 !!!!!!!

BTW if you are J of A does it mean us English have got to burn you again - is
that what you understand by a flame? :-)

Anton

- John of Arc - wrote:

> How does one represent large numbers like the int64 (e.g. file times) in VB?
>
> Thanks.

--

Anton Britten

EMail :- anton@brittena.demon.co.uk
or AntonBritten@compuserve.com

Web site :- www.brittena.demon.co.uk

Anton Britten Computing Ltd
You find sympathy in the dictionary
- between sh*t and syphilis !
Anton Britten at 2007-11-11 20:07:16 >
# 4 Re: how to represent int64 in VB?
If you are passing by reference pass the first long of a long array of two
elements eg

dim l(1 to 2) as long

call someroutine(l(1))

BUT don't forget the number will come back reversed

so if you had a value 1 in the 64 bit number hex H00000000 00000001

it will come back as

l(1) = H00000001
l(2) = H00000000 !!!!!!!

BTW if you are J of A does it mean us English have got to burn you again - is
that what you understand by a flame? :-)

Anton

- John of Arc - wrote:

> How does one represent large numbers like the int64 (e.g. file times) in VB?
>
> Thanks.

--

Anton Britten

EMail :- anton@brittena.demon.co.uk
or AntonBritten@compuserve.com

Web site :- www.brittena.demon.co.uk

Anton Britten Computing Ltd
You find sympathy in the dictionary
- between sh*t and syphilis !
Anton Britten at 2007-11-11 20:08:16 >
# 5 Re: how to represent int64 in VB?
> The short answer is that VB doesn't support 64 bit integers.

But it has a 64bits type: Currency.

--
Eduardo A. Morcillo
http://www.domaindlx.com/e_morcillo
Eduardo A. Morcillo at 2007-11-11 20:09:15 >
# 6 Re: how to represent int64 in VB?
> The short answer is that VB doesn't support 64 bit integers.

But it has a 64bits type: Currency.

--
Eduardo A. Morcillo
http://www.domaindlx.com/e_morcillo
Eduardo A. Morcillo at 2007-11-11 20:10:13 >
# 7 Re: how to represent int64 in VB?
Thanks for the technique.

I'm trying to handle file times, to be more specific.

Anton Britten <AntonBritten@compuserve.com> wrote in message
news:38CB5F2C.5890DC91@compuserve.com...
> If you are passing by reference pass the first long of a long array of two
> elements eg
>
> dim l(1 to 2) as long
>
> call someroutine(l(1))
>
> BUT don't forget the number will come back reversed
>
> so if you had a value 1 in the 64 bit number hex H00000000 00000001
>
> it will come back as
>
> l(1) = H00000001
> l(2) = H00000000 !!!!!!!
>
> BTW if you are J of A does it mean us English have got to burn you again -
is
> that what you understand by a flame? :-)
>
> Anton
>
> - John of Arc - wrote:
>
> > How does one represent large numbers like the int64 (e.g. file times) in
VB?
> >
> > Thanks.
>
> --
>
> Anton Britten
>
> EMail :- anton@brittena.demon.co.uk
> or AntonBritten@compuserve.com
>
> Web site :- www.brittena.demon.co.uk
>
> Anton Britten Computing Ltd
> You find sympathy in the dictionary
> - between sh*t and syphilis !
>
>
- John of Arc - at 2007-11-11 20:11:17 >
# 8 Re: how to represent int64 in VB?
Thanks for the technique.

I'm trying to handle file times, to be more specific.

Anton Britten <AntonBritten@compuserve.com> wrote in message
news:38CB5F2C.5890DC91@compuserve.com...
> If you are passing by reference pass the first long of a long array of two
> elements eg
>
> dim l(1 to 2) as long
>
> call someroutine(l(1))
>
> BUT don't forget the number will come back reversed
>
> so if you had a value 1 in the 64 bit number hex H00000000 00000001
>
> it will come back as
>
> l(1) = H00000001
> l(2) = H00000000 !!!!!!!
>
> BTW if you are J of A does it mean us English have got to burn you again -
is
> that what you understand by a flame? :-)
>
> Anton
>
> - John of Arc - wrote:
>
> > How does one represent large numbers like the int64 (e.g. file times) in
VB?
> >
> > Thanks.
>
> --
>
> Anton Britten
>
> EMail :- anton@brittena.demon.co.uk
> or AntonBritten@compuserve.com
>
> Web site :- www.brittena.demon.co.uk
>
> Anton Britten Computing Ltd
> You find sympathy in the dictionary
> - between sh*t and syphilis !
>
>
- John of Arc - at 2007-11-11 20:12:15 >
# 9 Re: how to represent int64 in VB?
Currency is not an integer type.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Eduardo A. Morcillo" <edanmo@geocities.com> wrote in message
news:38cb7ec1@news.dev-archive.com...
> > The short answer is that VB doesn't support 64 bit integers.
>
> But it has a 64bits type: Currency.
>
> --
> Eduardo A. Morcillo
> http://www.domaindlx.com/e_morcillo
>
>
Jonathan Wood at 2007-11-11 20:13:23 >
# 10 Re: how to represent int64 in VB?
Currency is not an integer type.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Eduardo A. Morcillo" <edanmo@geocities.com> wrote in message
news:38cb7ec1@news.dev-archive.com...
> > The short answer is that VB doesn't support 64 bit integers.
>
> But it has a 64bits type: Currency.
>
> --
> Eduardo A. Morcillo
> http://www.domaindlx.com/e_morcillo
>
>
Jonathan Wood at 2007-11-11 20:14:18 >
# 11 Re: how to represent int64 in VB?
Hi Jonathan --

>Currency is not an integer type.

Close enough. It's a "scaled integer" and works fine for the original question.

Later... Karl
Karl E. Peterson at 2007-11-11 20:15:22 >
# 12 Re: how to represent int64 in VB?
Hi Jonathan --

>Currency is not an integer type.

Close enough. It's a "scaled integer" and works fine for the original question.

Later... Karl
Karl E. Peterson at 2007-11-11 20:16:20 >
# 13 Re: how to represent int64 in VB?
Hi John --

>How does one represent large numbers like the int64 (e.g. file times) in VB?

Here's what I use:

Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

You can see a complete example at http://www.mvps.org/vb -- FileInfo.zip on the
Samples page.

Later... Karl
Karl E. Peterson at 2007-11-11 20:17:27 >
# 14 Re: how to represent int64 in VB?
Hi John --

>How does one represent large numbers like the int64 (e.g. file times) in VB?

Here's what I use:

Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

You can see a complete example at http://www.mvps.org/vb -- FileInfo.zip on the
Samples page.

Later... Karl
Karl E. Peterson at 2007-11-11 20:18:26 >
# 15 Re: how to represent int64 in VB?
Karl,

> Close enough. It's a "scaled integer" and works fine for the original
question.

It may work for what he wanted but that wasn't really clear to me because he
didn't indicate what he had to do with them.

To me, the better approach is to use a combination of longs and, looking at
your reply to him, looks like you agreed. :-)

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jonathan Wood at 2007-11-11 20:19:25 >
# 16 Re: how to represent int64 in VB?
Karl,

> Close enough. It's a "scaled integer" and works fine for the original
question.

It may work for what he wanted but that wasn't really clear to me because he
didn't indicate what he had to do with them.

To me, the better approach is to use a combination of longs and, looking at
your reply to him, looks like you agreed. :-)

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jonathan Wood at 2007-11-11 20:20:22 >
# 17 Re: how to represent int64 in VB?
You can replace FILETIME with Currency without any harm. Also you can use
Currency with any function/callback that expects a 64bits interger. The only
thing you have to do before passing it is divide it by 10000 and multiply it
by 10000 after receiving it.

--
Eduardo A. Morcillo
http://www.domaindlx.com/e_morcillo
"Jonathan Wood" <jwood@softcircuits.com> wrote in message
news:38cd35a8@news.dev-archive.com...
> Karl,
>
> > Close enough. It's a "scaled integer" and works fine for the original
> question.
>
> It may work for what he wanted but that wasn't really clear to me because
he
> didn't indicate what he had to do with them.
>
> To me, the better approach is to use a combination of longs and, looking
at
> your reply to him, looks like you agreed. :-)
>
> --
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
>
>
>
Eduardo A. Morcillo at 2007-11-11 20:21:30 >
# 18 Re: how to represent int64 in VB?
You can replace FILETIME with Currency without any harm. Also you can use
Currency with any function/callback that expects a 64bits interger. The only
thing you have to do before passing it is divide it by 10000 and multiply it
by 10000 after receiving it.

--
Eduardo A. Morcillo
http://www.domaindlx.com/e_morcillo
"Jonathan Wood" <jwood@softcircuits.com> wrote in message
news:38cd35a8@news.dev-archive.com...
> Karl,
>
> > Close enough. It's a "scaled integer" and works fine for the original
> question.
>
> It may work for what he wanted but that wasn't really clear to me because
he
> didn't indicate what he had to do with them.
>
> To me, the better approach is to use a combination of longs and, looking
at
> your reply to him, looks like you agreed. :-)
>
> --
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
>
>
>
Eduardo A. Morcillo at 2007-11-11 20:22:30 >
# 19 Re: how to represent int64 in VB?
Hi Jonathan --

>> Close enough. It's a "scaled integer" and works fine for the original
>> question.
>
>It may work for what he wanted but that wasn't really clear to me because he
>didn't indicate what he had to do with them.

I assumed he was using APIs that required a FILETIME structure.

>To me, the better approach is to use a combination of longs and, looking at
>your reply to him, looks like you agreed. :-)

Yep, that's where I go with 'em. Jim Mack, and later (I believe) Bruce McKinney,
published some cool routines that use Currency instead, so I guess opinions are mixed
on this one.

Later... Karl
Karl E. Peterson at 2007-11-11 20:23:27 >
# 20 Re: how to represent int64 in VB?
Hi Jonathan --

>> Close enough. It's a "scaled integer" and works fine for the original
>> question.
>
>It may work for what he wanted but that wasn't really clear to me because he
>didn't indicate what he had to do with them.

I assumed he was using APIs that required a FILETIME structure.

>To me, the better approach is to use a combination of longs and, looking at
>your reply to him, looks like you agreed. :-)

Yep, that's where I go with 'em. Jim Mack, and later (I believe) Bruce McKinney,
published some cool routines that use Currency instead, so I guess opinions are mixed
on this one.

Later... Karl
Karl E. Peterson at 2007-11-11 20:24:28 >
# 21 Re: how to represent int64 in VB?
Aha!

forgive my ignorance - what are the "low" and "high" parts? first 32 bits
and second 32-bits?

Karl E. Peterson <karl@mvps.org> wrote in message
news:38cd2a7e$1@news.dev-archive.com...
> Hi John --
>
> >How does one represent large numbers like the int64 (e.g. file times) in
VB?
>
> Here's what I use:
>
> Private Type FILETIME
> dwLowDateTime As Long
> dwHighDateTime As Long
> End Type
>
> You can see a complete example at http://www.mvps.org/vb -- FileInfo.zip
on the
> Samples page.
>
> Later... Karl
>
>
>
- John of Arc - at 2007-11-11 20:25:30 >
# 22 Re: how to represent int64 in VB?
Aha!

forgive my ignorance - what are the "low" and "high" parts? first 32 bits
and second 32-bits?

Karl E. Peterson <karl@mvps.org> wrote in message
news:38cd2a7e$1@news.dev-archive.com...
> Hi John --
>
> >How does one represent large numbers like the int64 (e.g. file times) in
VB?
>
> Here's what I use:
>
> Private Type FILETIME
> dwLowDateTime As Long
> dwHighDateTime As Long
> End Type
>
> You can see a complete example at http://www.mvps.org/vb -- FileInfo.zip
on the
> Samples page.
>
> Later... Karl
>
>
>
- John of Arc - at 2007-11-11 20:26:33 >
# 23 Re: how to represent int64 in VB?
- John of Arc - wrote in message <38cdca8c$1@news.dev-archive.com>...
>Aha!
>
>forgive my ignorance - what are the "low" and "high" parts? first 32 bits
>and second 32-bits?

Yes; if you have a 64 bit number, you can split it into two 32-bit parts (or
4 16-bit parts, etc, although it's less problematic to use the largest chunk
possible).

Mathematically, the low dword (4 bytes) would be your 64 bit number modulo
2^32, whereas the high dword would be your 64 bit number, integer divided by
2^32. I don't think the modulo operation in VB (mod) works with numbers
above 2^31, tho.

Programmatically, you're better off using CopyMemory.

--
Colin McGuigan
Colin McGuigan at 2007-11-11 20:27:28 >
# 24 Re: how to represent int64 in VB?
- John of Arc - wrote in message <38cdca8c$1@news.dev-archive.com>...
>Aha!
>
>forgive my ignorance - what are the "low" and "high" parts? first 32 bits
>and second 32-bits?

Yes; if you have a 64 bit number, you can split it into two 32-bit parts (or
4 16-bit parts, etc, although it's less problematic to use the largest chunk
possible).

Mathematically, the low dword (4 bytes) would be your 64 bit number modulo
2^32, whereas the high dword would be your 64 bit number, integer divided by
2^32. I don't think the modulo operation in VB (mod) works with numbers
above 2^31, tho.

Programmatically, you're better off using CopyMemory.

--
Colin McGuigan
Colin McGuigan at 2007-11-11 20:28:39 >