|
-
Mar 1st, 2002, 04:36 PM
#1
Thread Starter
PowerPoster
Double & Single
Can someone explain these 2 variable types to me please. integers & longs i understand but these 2 i'm not sure about.
I dim dbDub as Double and i set its value to 111,111,111,111,111 and it = 111billion,111million,111thousond,111. But when i add 1 more 1 it all of a sudden = 1.11111111111111E+15.
Now what does this mean? does it mean i now have 1.1 as a value or do i have 1 trillion,111billion,etc....
What is the difference in speed as compared to Longs and Integers?
Would i only use Doubles and Singles when i need to use decimal places?
Thanks!
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Mar 1st, 2002, 04:38 PM
#2
PowerPoster
Double is to Single as Long is to Integer.
Double and Single are both floating-point variables. The double can hold numbers twice as big. If you make them sufficiently large, they start displaying in scientific notation, and I think you may lose a small amount of accuracy.
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Mar 1st, 2002, 04:42 PM
#3
Frenzied Member
I believe
1.11111111111111E+15.
means
1.11111111111111 * 10^15
-
Mar 1st, 2002, 04:44 PM
#4
PowerPoster
That's scientific notation alright...
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Mar 1st, 2002, 05:55 PM
#5
-
Mar 1st, 2002, 06:56 PM
#6
Thread Starter
PowerPoster
Thaks alot riis for the tutorial and explination.. It helped alot.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Mar 1st, 2002, 07:40 PM
#7
PowerPoster
Originally posted by riis
Double precision floats have an accuracy of 15 decimals, so if you have larger numbers (or if you have more than 15 decimals, before and after the comma), doubles will never exactly hold the value you intended to.
Single precision floats only have an accuracy of 7 decimals. In most cases this is sufficient.
Just to set this straight.. a single is accurate to 7 places and not to 7 places after the decimal point and so it is not sufficient in most any cases that add monetary values eg accounting software, business etc
VB Code:
Private Sub Command1_Click()
Dim lVar As Single
Dim lVar2 As Single
lVar = 23456.78
lVar2 = 33456.31
Debug.Print lVar + lVar2 '56913.09
lVar = 123456.78
lVar2 = 133456.31
Debug.Print lVar + lVar2 '256913.1
lVar = 1023456.78
lVar2 = 1033456.31
Debug.Print lVar + lVar2 '2056913
lVar = 51023456.78
lVar2 = 51033456.31
Debug.Print lVar + lVar2 '1.020569E+08
End Sub
Hence the scientific notation that comes in after 7 places are used up.
Regards
-
Mar 1st, 2002, 08:11 PM
#8
Frenzied Member
Originally posted by rjlohan
Double is to Single as Long is to Integer.
Double and Single are both floating-point variables. The double can hold numbers twice as big. If you make them sufficiently large, they start displaying in scientific notation, and I think you may lose a small amount of accuracy.
Spreading false information are we?
1.79769313486231E+308 is one hell of a lot more than twice as large as 3.402823E+38.
You just proved that sig advertisements work.
-
Mar 3rd, 2002, 05:31 AM
#9
PowerPoster
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|