Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number Data types Newbie question

Status
Not open for further replies.

AndyLee100

Technical User
Jun 26, 2003
174
GB
I wonder if anyone can be kind enough to explain the differences between Long, Integer, Single and Double data types in VB 6.

I am a little confused mainly regarding Single and Double data types. Why are they called Single Floating point and double floating point. I have looked at all the help files but it doesnt explain it fully to me.

An overview of these would help my greatly.

Thanks in anticipation.

Andy Lee
 
The summary and specification of these data types are given here.

Different data types has different size and precision. For example the range of Integer is -32,768 to 32,767 and it takes 2 bytes in memory whereas Byte occupies only one byte and ranges from 0 to 255.

The difference between single and double is also mentioned. Single takes four bytes where as double takes 8 bytes and has wider range and better precision.

Note that in general, as the precision and size of these data types increases, their processing speed decreases and CPU takes more time to process and operate on them. Therefore we have to make a balance between performance and precesion.
 
A search in your VBHelp using "Data Type Summary" will take you to the page with the definitions.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
John

Yeah, thanks for the help. If you had read my post you would have noticed that I had looked in the help files. What is needed is a real world view from experienced developers and a bit more of an explanation which I think is missing from the help files.
 
Hi Andy,

Glad to be of any help.

I think you misunderstood John. He is a respected and very helpful contributor in this forum since long.

Perhaps you were offended by his advice to visit the FAQ regarding forum ethics and norms.

Note that this advice was not directed specially for you, but for all readers. It appears in his signature and is appended to all his posts in all the forums. This is a modest way to invite those people who haven't read that FAQ yet. It is not intended to humiliate or offend readers by any means.

I am sure that all the regular participants of this forum will second me.

I hope that this explanation clears the misunderstanding in your mind. Regards, and have a nice time.
 
I'll second you Hypetia.

John is one of our best.

Referring people to help files, msdn, faq's or previous threads is a very common and useful practice here. Why reiterate what has already been said, and usually said well.

zemp
 
Andy,
I have no wish to upset or humiliate you. My answer was to supply the exact search string for you. If you use that search string as quoted it takes you to exactly the same information as Hypetia's link.

To expand on Hypetia's explanation, for integer calculation in VB6 you will find it faster to use Longs rather than Integers or Bytes as Integers and Bytes are internally converted to Longs for calculation purposes (it's a 32-bit system). For Data Storage use the shortest type that fits.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
John,

On reflection I was a bit hasty with my reply. Must have had a bad day.

Please accept a sincere apology and thanks all for your answers.

Cheers

Andy
 
You're welcome - we're all here to help each other.[smile]

And seriously - the referenced faq in my sig is intended to give everyone simple guidelines on getting the best from the forum. You will find that several of the regular posters on this forum use it in their sigs.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top