473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB.NET Integer data types

Is the Integer data type deprecated? I am not sure what Integer data type to
use in some of my classes.

According to the URL below, if I am reading it correctly, it seems as though
I should be using the Short, Integer, and Long data types. Is this correct?
Or should I instead be using the Int16, 32, and 64 data types in my code?
Whats the best practice here?

http://www.ondotnet.com/pub/a/dotnet...b7.html?page=2
Jul 21 '05 #1
3 17750
This has been debated a few times on the NGs.
In general, the consensus is to use the Short, Integer, and Long keywords.
They of course translate directly to the Int16, 32, and 64 data types.
The debate has mostly been "will the underlying type vary in the future?"
At some point, it probably will, just has it has changed now.
But that time isn't in the foreseeable future. Maybe when the standard
processor architecture is 128bit or something.

However, in the cases where you know you need a specific size, which is
usually limited to external API calls and I/O, then I prefer to explicitly
declare the size. For me, when I see a declaration of Int32, that tells me
that I know I need exactly 32 bits for some reason. While it is no different
than "Integer", it is more "explicit" and serves as a flag to me when
reading my code later on that it might not be safe to alter the size.

As far as platform dependence, .NET has given us the IntPtr (Integer
Pointer) type. This is the one you should pay attention to. The underlying
type can vary based on whether you are on a 32 or 64 bit platform. Clearly
it should be used for pointers.

Gerald

"Shawn Berg" <sh***@saeweb.com> wrote in message
news:eY*************@TK2MSFTNGP12.phx.gbl...
Is the Integer data type deprecated? I am not sure what Integer data type to use in some of my classes.

According to the URL below, if I am reading it correctly, it seems as though I should be using the Short, Integer, and Long data types. Is this correct? Or should I instead be using the Int16, 32, and 64 data types in my code?
Whats the best practice here?

http://www.ondotnet.com/pub/a/dotnet...b7.html?page=2

Jul 21 '05 #2
Even though I use C++ .NET, I am faced a similar situation. I find it easiest
to use the language-specific names(short, int, long) when decaring variables,
but if is need to use it in an array decaration I use the .NET-specific
names(Int16, Int32, Int64). That way it takes less time to type, since there
really is no difference between the 2. I hope this helps.
Jul 21 '05 #3
Shawn,

The integer should give you the most properiate processor format. (with the
most performance). For the windows 32 bits operating systems is that 32
bits.

As Gerald tells are there a lot of discussions in the newsgroups if the
integer should stay 32 bits.

In my opinion would mean that the developer of that language will be the
looser in time in my opinion.

Any format (larger or smaller) that does not fit the register format needs
more cycles to proccess.

I hope that this helps,

Cor
Jul 21 '05 #4

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

Similar topics

30
by: JKop | last post by:
When you want to store an integer in C++, you use an integral type, eg. int main() { unsigned char amount_legs_dog = 4; } In writing portable C++ code, there should be only two factors that...
13
by: Shailesh Humbad | last post by:
I wrote a short page as a quick reference to c++ integer data types. Any feedback welcome: http://www.somacon.com/blog/page11.php
20
by: GS | last post by:
The stdint.h header definition mentions five integer categories, 1) exact width, eg., int32_t 2) at least as wide as, eg., int_least32_t 3) as fast as possible but at least as wide as, eg.,...
61
by: John Baker | last post by:
When declaring an integer, you can specify the size by using int16, int32, or int64, with plain integer being int32. Is integer the accepted default in the programming community? If so, is...
3
by: Shawn Berg | last post by:
Is the Integer data type deprecated? I am not sure what Integer data type to use in some of my classes. According to the URL below, if I am reading it correctly, it seems as though I should be...
5
by: BobRoyAce | last post by:
Let's say I have a table called Users which has a field DeptID which is an int. I also have a User class which has a method for getting the data for a particular user (i.e. User with specified ID)...
159
by: Bob Timpkinson | last post by:
Hi, I have a 32-bit machine... Is there anyway I can get gcc to use the following integer sizes? char: 8 bits short: 16 bits int: 32 bits long: 64 bits long long: 128 bits
130
by: euler70 | last post by:
char and unsigned char have specific purposes: char is useful for representing characters of the basic execution character set and unsigned char is useful for representing the values of individual...
12
by: lithiumcat | last post by:
Hi, I bothered you a while back about storing integer values in void*. Now in a completely unrelated context, I'm trying to store pointer values in an integer type. So the basic question is,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.