unsigned long ? 
Author Message
 unsigned long ?

Hi,

under VB there is the long type on 4 bytes : -2 147 483 648 to 2 147 483 647
but is there a way to treat this a a real DWORD, i.e. an unsigned long
from 0 to 4 290 000 000 ? By treat I mean calculation, printing, etc...

a "single" does not seem to do that because it is in scientific notation...

thanks

david.



Fri, 09 Aug 2002 03:00:00 GMT  
 unsigned long ?


Quote:
> Hi,

> under VB there is the long type on 4 bytes : -2 147 483 648 to 2 147 483
647
> but is there a way to treat this a a real DWORD, i.e. an unsigned long
> from 0 to 4 290 000 000 ? By treat I mean calculation, printing, etc...

> a "single" does not seem to do that because it is in scientific
notation...

A DOUBLE should give you the range that you need.

Cheers

Derek



Fri, 09 Aug 2002 03:00:00 GMT  
 unsigned long ?



Quote:



> > under VB there is the long type on 4 bytes : -2 147 483 648 to 2 147 483
> 647
> > but is there a way to treat this a a real DWORD, i.e. an unsigned long
> > from 0 to 4 290 000 000 ? By treat I mean calculation, printing, etc...

> > a "single" does not seem to do that because it is in scientific
> notation...

> A DOUBLE should give you the range that you need.

Still in scientific notation... The Currency data type (a scaled 8-byte
integer, if I recall correctly) has large enough a range and up to 4
decimals (actual ones, as in the number stored in memory is devided by
10000)

    Frits van Bommel



Fri, 09 Aug 2002 03:00:00 GMT  
 unsigned long ?

Quote:

>Still in scientific notation... The Currency data type (a scaled 8-byte
>integer, if I recall correctly) has large enough a range and up to 4
>decimals (actual ones, as in the number stored in memory is devided by
>10000)

The Decimal data type (subtype of Variant, use CDec), gives more than
28 digits, with number of decimal places variable from 0 to 28.
--

Sun Valley Systems    http://www.sunvaley.com
"For God so loved the world that He gave His only begotten Son, that
whoever believes in Him should not perish but have everlasting life."


Fri, 09 Aug 2002 03:00:00 GMT  
 unsigned long ?

Quote:





> > > under VB there is the long type on 4 bytes : -2 147 483 648 to 2 147 483
> > 647
> > > but is there a way to treat this a a real DWORD, i.e. an unsigned long
> > > from 0 to 4 290 000 000 ? By treat I mean calculation, printing, etc...

> > > a "single" does not seem to do that because it is in scientific
> > notation...

> > A DOUBLE should give you the range that you need.

> Still in scientific notation...

The scientific notation is just a representation issue. You might be able to
use the Format$() function to overcome that.

--
MikeC

Please reply to the group.

  MikeC.vcf
< 1K Download


Fri, 09 Aug 2002 03:00:00 GMT  
 unsigned long ?



Quote:

> >Still in scientific notation... The Currency data type (a scaled 8-byte
> >integer, if I recall correctly) has large enough a range and up to 4
> >decimals (actual ones, as in the number stored in memory is devided by
> >10000)

> The Decimal data type (subtype of Variant, use CDec), gives more than
> 28 digits, with number of decimal places variable from 0 to 28.

I've not really got a lot of VB experience, I just recalled that from PDS...

    Frits van Bommel



Sun, 11 Aug 2002 03:00:00 GMT  
 unsigned long ?



Quote:


berichtnieuws
> > > A DOUBLE should give you the range that you need.

> > Still in scientific notation...

> The scientific notation is just a representation issue. You might be able
to
> use the Format$() function to overcome that.

The main problem I have with it is that it's inaccurate, since there's a lot
of numbers that can't be expressed as well in binary scientific notation as
they can be in any decimal form.
For example, .2 can't be precisely represented in binary scientific
notation, while it can be in any decimal form.

    Frits van Bommel



Sun, 11 Aug 2002 03:00:00 GMT  
 unsigned long ?

Quote:




> > > > A DOUBLE should give you the range that you need.

> > > Still in scientific notation...

> > The scientific notation is just a representation issue. You might be able
> > to use the Format$() function to overcome that.

> The main problem I have with it is that it's inaccurate, since there's a lot
> of numbers that can't be expressed as well in binary scientific notation as
> they can be in any decimal form.
> For example, .2 can't be precisely represented in binary scientific
> notation, while it can be in any decimal form.

Why are we discussing 0.2 here? Didn't you start this thread by asking for
unsigned long? Were you planning to shove 0.2 into an unsigned long?

Single and Double data types have no trouble representing whole numbers.

--
MikeC

Please reply to the group.

  MikeC.vcf
< 1K Download


Sun, 11 Aug 2002 03:00:00 GMT  
 unsigned long ?



Quote:
> Why are we discussing 0.2 here? Didn't you start this thread by asking for
> unsigned long? Were you planning to shove 0.2 into an unsigned long?

No I didn't. Somebody who called himself "Haubensack" did. Hasn't posted
anything in this thread ever since.
Right now I'm discussing the disadvantages of Singles and Doubles.

Quote:
> Single and Double data types have no trouble representing whole numbers.

Except they're not totally accurate when it comes to large numbers.

    Frits van Bommel



Sun, 11 Aug 2002 03:00:00 GMT  
 unsigned long ?



Quote:



> > Why are we discussing 0.2 here? Didn't you start this thread by asking
for
> > unsigned long? Were you planning to shove 0.2 into an unsigned long?

> No I didn't. Somebody who called himself "Haubensack" did. Hasn't posted
> anything in this thread ever since.
> Right now I'm discussing the disadvantages of Singles and Doubles.

> > Single and Double data types have no trouble representing whole numbers.

> Except they're not totally accurate when it comes to large numbers.

That's true of course, but a DOUBLE is perfectly capable of representing an
unsigned LONG with complete accuracy.  In fact even 2^48 can be represented
exactly by a DOUBLE.  Also DOUBLEs have the advantage that they exist in
GWBASIC, QBASIC, QuickBASIC PDS, VBDOS, VBWin and powerbasic, so they can be
used even when you are stuck with a system which doesn't have the useful
CURRENCY type.

Cheers

Derek



Sun, 11 Aug 2002 03:00:00 GMT  
 unsigned long ?
If you are calling a routine which wants an "unsigned long", just pass it a
"signed long" making the sign adjustments in the call-ING routine. Whatever
the routine is, it doesn't care HOW you set bit 31 (the sign bit), it just
cares that it IS set, and that there are 32 bits worth of "owned" memory at
the pointer location (if passing by reference) or on the stack (when passing
by value).

Let's say you want to send the value &hFE123456, which, as a positive
number, is beyond the range of a signed long. So, send it, with CALL MyProc
( CVL(CHR$(&h56) & CHR$(&h34) & CHR$(&h12) & CHR$(&hFE)) (I reversed the
bytes to get the data in Intel format).

Reading it back is left as an exercise for the reader. Arithmetic on the
result is the responsibility of the user.

--
Michael Mattias
Racine WI USA

Quote:






[stuff about passing an unsigned long from VB to something)


Mon, 12 Aug 2002 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. unsigned long ?

2. Unsigned Long Integers in VB5

3. unsigned longs..

4. unsigned long vars in vb ?

5. HELP: Converting Unsigned Long?

6. Unsigned Long Math

7. Unsigned Long Values - Need Help

8. Do unsigned Longs exist ??????

9. unsigned Long

10. Visual Basic Data type question (UNSIGNED LONGS POSSIBLE??)

11. Unsigned Long

12. Visual Basic Data type question (UNSIGNED LONGS POSSIBLE??)

 

 
Powered by phpBB® Forum Software