473,805 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

int64 or double

cj
VB2003. I need a large positive integer. Which is larger int64 or double?

I see int64 also apparently is known as long and will hold
-9,223,372,036,8 54,775,808 through 9,223,372,036,8 54,775,807.

But I'm not good with the E+??? notation so when I'm told double holds
-1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values.

What does that mean? is -1.7976931348623 1570E+308 =
-1.7976931348623 1570 X whatever 1 with 308 zeros behind it is?

Plus double doesn't seem to hold 1, 2, 3, 4, 5 etc cause it gives two
ranges.

Sorry, I always felt math was for the computer to figure out not me.
May 12 '06 #1
14 9650
Double.MaxValue should be large enough.

the +308 means how many times you have to shift the decimal period to
the right (like if you multiply times 10 raised to 308). Try writing
this:
MsgBox(1E1)

in your compiler and see what happens ;-)

-t

May 12 '06 #2
"cj" <cj@nospam.nosp am> wrote in message
news:ez******** ******@TK2MSFTN GP03.phx.gbl...
VB2003. I need a large positive integer. Which is larger int64 or
double?
Double is larger - but it lacks the precision of integer
variables. Integers are exact. Floating point numbers
are only close approximations. So, do you need an exact representation or
will an approximation do?
I see int64 also apparently is known as long and will
hold -9,223,372,036,8 54,775,808 through 9,223,372,036,8 54,775,807.
Is this large enough? If it is, use it. If not take a look at the
Decimal type as well as Double.
But I'm not good with the E+??? notation so when I'm told double holds
-1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values.

What does that mean? is -1.7976931348623 1570E+308 = -1.7976931348623 1570
X whatever 1 with 308 zeros behind it is?

Plus double doesn't seem to hold 1, 2, 3, 4, 5 etc cause it gives two
ranges.

Sorry, I always felt math was for the computer to figure out not me.


How will you know if the computer is giving you the right answer?

--
Charles Appel
http://charlesappel.home.mindspring.com/
Home of Chuck's Poker Libraries for Delphi,
Chuck's Video Poker and Chuck's Toys
May 12 '06 #3

"Charles Appel" <ch**********@m indspring.com> wrote in message
news:uZ******** ******@TK2MSFTN GP03.phx.gbl...
"cj" <cj@nospam.nosp am> wrote in message
news:ez******** ******@TK2MSFTN GP03.phx.gbl...
VB2003. I need a large positive integer. Which is larger int64 or
double?


Double is larger - but it lacks the precision of integer
variables. Integers are exact. Floating point numbers
are only close approximations. So, do you need an exact representation or
will an approximation do?
I see int64 also apparently is known as long and will
hold -9,223,372,036,8 54,775,808 through 9,223,372,036,8 54,775,807.


Is this large enough? If it is, use it. If not take a look at the
Decimal type as well as Double.
But I'm not good with the E+??? notation so when I'm told double holds
-1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values.

What does that mean? is -1.7976931348623 1570E+308 = -1.7976931348623 1570 X whatever 1 with 308 zeros behind it is?

Plus double doesn't seem to hold 1, 2, 3, 4, 5 etc cause it gives two
ranges.

Sorry, I always felt math was for the computer to figure out not me.


How will you know if the computer is giving you the right answer?

--
Charles Appel
http://charlesappel.home.mindspring.com/
Home of Chuck's Poker Libraries for Delphi,
Chuck's Video Poker and Chuck's Toys


In addition to Charles' comments...
Note that while a Double can have in excessive 300 digits of "precision" ,
only the first 16 or so digits are "accurate". This can lead to a very long
discussion, but while you might be able to get a very long number, it is
really only an approximation, of which the first 16 digits or so are
accurate.
Note how they described the limits:
1.7976931348623 1570E+308 for positive values
They use that notation for a reason. Only the digits listed could be
considered close to accurate, the other 291 digits it can "display" are only
an approximation.

You started by saying that you need a very large positive Integer. Well, if
that is what you need, then you should stick with Integers. Going back and
forth can cause you to lose accuracy.

Gerald
May 12 '06 #4
Just how 'large' an integer do you actually need?

To put the upper limit for an Int64 (Long) into perspective, it is
approximately 184 million times the approximate human population of the
earth.

It also equates to the number of miles in aproxiamately 1.571 million light
years.

If you consider to represent days, it also equates to aproxiamately 1.262
million times the number of days since the big bang.

"cj" <cj@nospam.nosp am> wrote in message
news:ez******** ******@TK2MSFTN GP03.phx.gbl...
VB2003. I need a large positive integer. Which is larger int64 or
double?

I see int64 also apparently is known as long and will
hold -9,223,372,036,8 54,775,808 through 9,223,372,036,8 54,775,807.

But I'm not good with the E+??? notation so when I'm told double holds
-1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values.

What does that mean? is -1.7976931348623 1570E+308 = -1.7976931348623 1570
X whatever 1 with 308 zeros behind it is?

Plus double doesn't seem to hold 1, 2, 3, 4, 5 etc cause it gives two
ranges.

Sorry, I always felt math was for the computer to figure out not me.

May 13 '06 #5
cj
While I'm on the subject why would anyone use a floating point number
(double or single) if they're inaccurate? Why not use decimal? Other
than the decimal takes 16 bytes vs the doubles 8.

Also I'm still not sure why double and single list the values they
accept in two ranges one for each side of 0. Do they not accept values
around 0? I'm sure they do but the documentation doesn't make sense to me.

ie: -1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values

cj wrote: VB2003. I need a large positive integer. Which is larger int64 or double?

I see int64 also apparently is known as long and will hold
-9,223,372,036,8 54,775,808 through 9,223,372,036,8 54,775,807.

But I'm not good with the E+??? notation so when I'm told double holds
-1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values.

What does that mean? is -1.7976931348623 1570E+308 =
-1.7976931348623 1570 X whatever 1 with 308 zeros behind it is?

Plus double doesn't seem to hold 1, 2, 3, 4, 5 etc cause it gives two
ranges.

Sorry, I always felt math was for the computer to figure out not me.

May 13 '06 #6
cj
Thanks for putting it into perspective. The answer is I don't really
know how big a number I will need. This is a counter that counts up but
I really don't know how fast as it will be based on usage. Being
careful makes me try for a type that'll hold a number it'll never hit or
perhaps I can reset it to 0 at some value but I'm not sure yet. Frankly
I'll have to do some thinking on that. double, decimal are I'm sure
large enough I wouldn't have to worry about reseting it. Frankly a
integer might be ok but I'd probably have to put in a reset just in case.

anyway thinking about all this makes me wonder about how they all fit
and which ones I'll probably use in the future. mostly I use decimal
and integer now.
Stephany Young wrote:
Just how 'large' an integer do you actually need?

To put the upper limit for an Int64 (Long) into perspective, it is
approximately 184 million times the approximate human population of the
earth.

It also equates to the number of miles in aproxiamately 1.571 million light
years.

If you consider to represent days, it also equates to aproxiamately 1.262
million times the number of days since the big bang.

"cj" <cj@nospam.nosp am> wrote in message
news:ez******** ******@TK2MSFTN GP03.phx.gbl...
VB2003. I need a large positive integer. Which is larger int64 or
double?

I see int64 also apparently is known as long and will
hold -9,223,372,036,8 54,775,808 through 9,223,372,036,8 54,775,807.

But I'm not good with the E+??? notation so when I'm told double holds
-1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values.

What does that mean? is -1.7976931348623 1570E+308 = -1.7976931348623 1570
X whatever 1 with 308 zeros behind it is?

Plus double doesn't seem to hold 1, 2, 3, 4, 5 etc cause it gives two
ranges.

Sorry, I always felt math was for the computer to figure out not me.


May 13 '06 #7
The important thing is, for each range, to look at the signs of the
exponents.

The sign of the exponent indicates the direction in which to move the
decimal point.

+ means move the decimal to the right

- means move the decimal point to the left

To simplfy it for demonstration purposes let's take a floating point type
that allows the ranges:

-1.79E+3 to -4.94E-3
and
4.94E-3 to 1.79E+3

-1.79E+3 equates to -1790
-4.94E-3 equates to -0.00494
4.94E-3 equates to 0.00494
1.79E+3 equates to 1790

Remembering that not every number can be represented exactly in floating
point, you can see that we have ranges of:

-1790 through -0.00494 negative values
and
0.00494 through 1790 negative values

1790 is the upper limit, -1790 is the lower limit and the closest
representations of 0 that we can achieve are 0.00494 and -0.00494.

Now, extrapolate that example up to the Double type and you can see that the
ranges are:

-1.7976931348623 1570E+308 through -4.9406564584124 6544E-324 for negative
values
and
4.9406564584124 6544E-324 through 1.7976931348623 1570E+308 for positive
values

This can be rewritten as:
-179769313486231 570[...300 zeroes...]00000000
through
-0.000000[...310 zeroes...]000494065645841 246544
for negative values
and
0.000000[...310 zeroes...]000494065645841 246544
through
179769313486231 570[...300 zeroes...]00000000
for positive values

This shows that 0 cannot be represented exactly as a Double and the closest
representations of 0 that can be achieved are actually:

-0.000000[...310 zeroes...]000494065645841 246544
and
0.000000[...310 zeroes...]000494065645841 246544

Now, when it comes to dealing with the Decimal type, it holds a signed
128-bit (16-byte) value representing a 96-bit (12-byte) integer number
scaled by a variable power of 10.

The scaling factor specifies the number of digits to the right of the
decimal point and ranges from 0 through 28.

With a scale of 0 (no decimal places), the largest possible value is
+/-79,228,162,514, 264,337,593,543 ,950,335
(+/-7.9228162514264 337593543950335 E+28).

With 28 decimal places, the largest value is
+/-7.9228162514264 337593543950335 , and the smallest nonzero value is
+/-0.0000000000000 000000000000001 (+/-1E-28).

As you can see, for each decimal place that you have, you lose one integral
place and vice-versa.

With no decimal places you can have the equivalent of a 29 digit number with
a range of +79,228,162,514 ,264,337,593,54 3,950,335
to -79,228,162,514, 264,337,593,543 ,950,335.

This is 10 digits wider than an Int64 (Long) and the maximum value is
approximately 8.5 bollions times larger.

"cj" <cj@nospam.nosp am> wrote in message
news:uD******** ********@TK2MSF TNGP02.phx.gbl. ..
While I'm on the subject why would anyone use a floating point number
(double or single) if they're inaccurate? Why not use decimal? Other
than the decimal takes 16 bytes vs the doubles 8.

Also I'm still not sure why double and single list the values they accept
in two ranges one for each side of 0. Do they not accept values around 0?
I'm sure they do but the documentation doesn't make sense to me.

ie: -1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values

cj wrote:
VB2003. I need a large positive integer. Which is larger int64 or
double?

I see int64 also apparently is known as long and will
hold -9,223,372,036,8 54,775,808 through 9,223,372,036,8 54,775,807.

But I'm not good with the E+??? notation so when I'm told double holds
-1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values.

What does that mean? is -1.7976931348623 1570E+308 = -1.7976931348623 1570
X whatever 1 with 308 zeros behind it is?

Plus double doesn't seem to hold 1, 2, 3, 4, 5 etc cause it gives two
ranges.

Sorry, I always felt math was for the computer to figure out not me.

May 13 '06 #8
OK. The use you have described puts it into perspective straight away.

If an Int32 counter is incremented once per second, 24/7 forever then it
will blow out early in the 69th year

If an Int64 counter is incremented once per second, 24/7 forever then it
will blow out early in the 292,271,024th millenium

If an Int32 counter is incremented once per millisecond, 24/7 forever then
it will blow out early in the 5th year

If an Int64 counter is incremented once per millisecond, 24/7 forever then
it will blow out early in the 4,872 millenium

If a Decimal (with 0 decimal places) counter is used then the blow out point
will be considerably longer.

If you expect the counter to be incremented no more frequently than once per
millisecond and don't expect it to keep counting for more than 4 years
without being reset then an Int32 (Integer) will suffice.

"cj" <cj@nospam.nosp am> wrote in message
news:ui******** ******@TK2MSFTN GP03.phx.gbl...
Thanks for putting it into perspective. The answer is I don't really know
how big a number I will need. This is a counter that counts up but I
really don't know how fast as it will be based on usage. Being careful
makes me try for a type that'll hold a number it'll never hit or perhaps I
can reset it to 0 at some value but I'm not sure yet. Frankly I'll have
to do some thinking on that. double, decimal are I'm sure large enough I
wouldn't have to worry about reseting it. Frankly a integer might be ok
but I'd probably have to put in a reset just in case.

anyway thinking about all this makes me wonder about how they all fit and
which ones I'll probably use in the future. mostly I use decimal and
integer now.
Stephany Young wrote:
Just how 'large' an integer do you actually need?

To put the upper limit for an Int64 (Long) into perspective, it is
approximately 184 million times the approximate human population of the
earth.

It also equates to the number of miles in aproxiamately 1.571 million
light years.

If you consider to represent days, it also equates to aproxiamately 1.262
million times the number of days since the big bang.

"cj" <cj@nospam.nosp am> wrote in message
news:ez******** ******@TK2MSFTN GP03.phx.gbl...
VB2003. I need a large positive integer. Which is larger int64 or
double?

I see int64 also apparently is known as long and will
hold -9,223,372,036,8 54,775,808 through 9,223,372,036,8 54,775,807.

But I'm not good with the E+??? notation so when I'm told double holds
-1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values; 4.9406564584124 6544E-324
through 1.7976931348623 1570E+308 for positive values.

What does that mean? is -1.7976931348623 1570E+308
= -1.7976931348623 1570 X whatever 1 with 308 zeros behind it is?

Plus double doesn't seem to hold 1, 2, 3, 4, 5 etc cause it gives two
ranges.

Sorry, I always felt math was for the computer to figure out not me.


May 13 '06 #9
If you use it for a counter, you should definitely use an integer data
type, not a floating point type.

When you reach the limit of an integer, you get an overflow, but when
you reach the limit of a floating point number, it just stops counting,
as an increase of one has become too small to make a difference.

Also, an integer can count longer than a floating point number of the
same size.

The number of bits that a double and an int64 occupies are the same. In
the int64, 63 bits are used for the number, and one bit for the sign. In
a double, 52 bits are used for the number, 11 bits for the exponent, and
one bit for the sign. That means that an int64 can hold a number that is
2048 times larger than the number that a double accurately can handle.
For the use as a counter, the 11 bits used for exponent are wasted.

cj wrote:
Thanks for putting it into perspective. The answer is I don't really
know how big a number I will need. This is a counter that counts up but
I really don't know how fast as it will be based on usage. Being
careful makes me try for a type that'll hold a number it'll never hit or
perhaps I can reset it to 0 at some value but I'm not sure yet. Frankly
I'll have to do some thinking on that. double, decimal are I'm sure
large enough I wouldn't have to worry about reseting it. Frankly a
integer might be ok but I'd probably have to put in a reset just in case.

anyway thinking about all this makes me wonder about how they all fit
and which ones I'll probably use in the future. mostly I use decimal
and integer now.
Stephany Young wrote:
Just how 'large' an integer do you actually need?

To put the upper limit for an Int64 (Long) into perspective, it is
approximately 184 million times the approximate human population of
the earth.

It also equates to the number of miles in aproxiamately 1.571 million
light years.

If you consider to represent days, it also equates to aproxiamately
1.262 million times the number of days since the big bang.

"cj" <cj@nospam.nosp am> wrote in message
news:ez******** ******@TK2MSFTN GP03.phx.gbl...
VB2003. I need a large positive integer. Which is larger int64 or
double?

I see int64 also apparently is known as long and will hold
-9,223,372,036,8 54,775,808 through 9,223,372,036,8 54,775,807.

But I'm not good with the E+??? notation so when I'm told double holds
-1.7976931348623 1570E+308 through
-4.9406564584124 6544E-324 for negative values;
4.9406564584124 6544E-324 through 1.7976931348623 1570E+308 for
positive values.

What does that mean? is -1.7976931348623 1570E+308 =
-1.7976931348623 1570 X whatever 1 with 308 zeros behind it is?

Plus double doesn't seem to hold 1, 2, 3, 4, 5 etc cause it gives two
ranges.

Sorry, I always felt math was for the computer to figure out not me.


May 13 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2247
by: Guy Jacubovs | last post by:
Hi i have a property on a COM which returns int64: var Milliseconds=Form1.Player.AbsolutePosition; however for somereason the typeof(Milliseconds) isn't number but unknown.... I can't make any use of this.
2
1903
by: Jon Ripley | last post by:
Hi, This function should return the integer portion of a float truncating down to -infinity. Where int64(12.34) = 12 and int64(-12.34) = -13 but int64(-12) = -12. In reality the function is called with a pointer to a double. void int64 ( double *num ) {
6
1742
by: David Hoffer | last post by:
Does C# have the same problem as C++ with code like this? if (GetDouble1() == GetDouble2()) { } In C++, due to the IEEE storage format, it is possible to have 2 doubles that are essentially the same value but not quite, so the above code will not do what you expect. Boost has some extensions to STL to solve this problem.
4
2167
by: Simon Devlin | last post by:
Hi folks, I've been bashing my head against this all afternoon and am now totally baffled. Given this (a simple routine to turn a ip address string into an decimal) <snip> Dim Parts(3) as string ' --> each element is an integer in the range 0-255 Dim Big as int64 = 0
5
5330
by: harishashim | last post by:
I have gone through necessary step and have been able to use a .Net libraries (created using C#) in VB6. It run good untill I try to use certain function in the library that is using Int64 type as parameter. VB6 give the following error Compile Error: Function or interface marked as restricted, or the function use an automation type not supported in Visual Basic.
8
5463
by: abdul_n_khan | last post by:
Hello, I have a basic question related to datatypes. I am trying to read a value using Microsoft's ADO recordset from a field (lets call it 'Price') with datatype decimal(19,6) => 19 = Precision, 6 = Scale 1) When I read this field into float datatype. I get a value 1.9000, which is correct. But when I read its value in a double datatype I get 1.8999999761581.
17
4389
by: Terry | last post by:
I have some old VB5 functions that specify types of Long and Double that make calls to an unmanaged 3rd party DLL probably just as old. The source for the DLL is not available. I'm getting some warnings "PInvoke..unbalanced stack..." etc. Reading up a bit on this and trying to understand this particular warning, I find that part of the problem could be in the mismatch of allocated space for the variables, e.g. VB5 Long is not the same as...
12
3041
by: Allen | last post by:
My C extension works wrong, and debug it, found that sizeof (INT64) = 4, not 8. I compile on Windows XP platform. Please tell me how to fix it to support INT64? Thanks.
8
2100
by: =?Utf-8?B?bXIgcGVhbnV0?= | last post by:
Is there a difference between: private Double B = new double; and private double E = new double; The editor shows the Double in aqua and double in blue leading me to think so. But the screen tip indicates they are equivalent.
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10609
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10105
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9185
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5542
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.