473,545 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Integer Do's And Don'ts

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 there a way to remove the ones with size predefined from the
autolisting of types when I am declaring something?
--
To Email Me, ROT13 My Shown Email Address

Nov 21 '05 #1
61 3304
Hi,

I don't think you can remove them from the drop down. The best bet is to
use just plain Integer. That will assure that you are using a 32-bit
integer and right now it is the fastest because it plays well with 32bit
boundaries that are using in 32bit programming models. If you are going to
mix them up then remember to put Option Strict On at the top of your code
pages. This will save you headaches when it comes to converting between
them in calculations and assignments. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"John Baker" <wb********@wzw freivprf.pbz> wrote in message
news:Sy******** *********@fe1.c olumbus.rr.com. ..
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 there a way to remove the ones with size predefined from the
autolisting of types when I am declaring something?
--
To Email Me, ROT13 My Shown Email Address

Nov 21 '05 #2
At one time I got the impression that Integer was a generic term that would
map to the native integer size of the environment in which you were running.
There was also some sort of guarantee that it would not be smaller than
Int32. This would ensure you would get the best performance if you did not
need a particular size.
In the future, Integer might map to Int64, Long might map to Int128, or
whatever.

However, I have also read a number of things countering this saying Integer
will always map to Int32. The first argument made more sense to me, but I
truly do not know the future plans.

But to be on the safe side, here is what I do.
If all I need is a generic integer of at least size Int32, then just use the
Integer keyword, which is almost always the case.
If I am dealing with things like bit-fields or reading datablocks from files
that I know are a specific size, then I explicitly declare the integer size.

Gerald

"John Baker" <wb********@wzw freivprf.pbz> wrote in message
news:Sy******** *********@fe1.c olumbus.rr.com. ..
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 there a way to remove the ones with size predefined from the
autolisting of types when I am declaring something?
--
To Email Me, ROT13 My Shown Email Address

Nov 21 '05 #3
"John Baker" <wb********@wzw freivprf.pbz> schrieb:
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?
There are different standpoints on the question of preferring the aliases
over the type names as they can be found in the .NET Framework.

Personally, I use 'Integer', 'Short', ... when I am writing fully managed
code. When interoperating with unmanaged code, I prefer the more low-level
names, 'Int32', 'Int16', ...
If so, is there a way to remove the ones with size predefined from the
autolisting of types when I am declaring something?


No.

--
Herfried K. Wagner [Microsoft MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #4
John,

Because there are different opinions, I go for as far as now posted Ken.
What is almost the same as for Gerald, however your question was Integer not
any other special format that has to be used, because it is needed in that
special format, so I am not sure what he mean with that, however I think the
same as Ken and me.

The Integer keyword ensures you that after recompiling the machine most
properiate format is used. Any other format can lead (now or in future) to
extra processing time when it is not optimized by the compiler.

Just my thought

Cor

"John Baker" <wb********@wzw freivprf.pbz>
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 there a way to remove the ones with size predefined from the
autolisting of types when I am declaring something?
--
To Email Me, ROT13 My Shown Email Address

Nov 21 '05 #5

"Cor Ligthert" <no************ @planet.nl> wrote
The Integer keyword ensures you that after recompiling the machine most
properiate format is used.

Is that documented? Where?

LFS
Nov 21 '05 #6
Larry,
The Integer keyword ensures you that after recompiling the machine most
properiate format is used.


Is that documented? Where?

Larry read the answer again, there is in my opinion not any need for
documentation, do you think that Int16 ensures you that (read in the
question as well and see that we are talking about integers).

Cor
Nov 21 '05 #7
Larry,

When sending my previous answer about CDate to somebody else, I remembered
me that it is documented in this page.

This is the text
Data Type Width
The most efficient data types are those that use the native data width of
the run-time platform. On current platforms, the data width is 32 bits, for
both the computer and the operating system.

Consequently, Integer is currently the most efficient data type in Visual
Basic .NET. Next best are Long, Short, and Byte, in that order of
efficiency. You can improve the performance of Short and Byte by turning off
integer overflow checking, for example by setting the RemoveIntegerCh ecks
property, but this incurs the risk of incorrect calculations due to
undetected overflows. You cannot toggle this checking on and off during run
time; you can only set its value for the next build of your application.

If you need fractional values, the best choice is Double, because the
floating-point processors of current platforms perform all operations in
double precision. Next best are Single and Decimal, in that order of
efficiency.

http://msdn.microsoft.com/library/de...tchPerfOpt.asp

I hope this is where you are looking for when your question was purely about
the documentation and not for discussion.

Cor
Nov 21 '05 #8
Larry,

"Larry Serflaten" <se*******@usin ternet.com> schrieb:
The Integer keyword ensures you that after recompiling the machine most
properiate format is used.


Is that documented? Where?


Nope. 'Integer' always maps to 'System.Int32'. That's documented here:

Visual Basic Language Reference -- 'Integer' Data Type
<URL:http://msdn.microsoft. com/library/en-us/vblr7/html/vadatinteger.as p>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #9

"Cor Ligthert" <no************ @planet.nl> wrote

The most efficient data types are those that use the native data width of
the run-time platform. <...> Consequently, Integer is currently the most efficient data type in Visual
Basic .NET.


But that does not say what you indicated, that using Integer will ensure you get
the most efficient (native) type. An Integer is always 32 bits on every system:

"Integer variables are stored as signed 32-bit (4-byte) integers ranging in value from -2,147,483,648 through 2,147,483,647"
The only two that I have heard of, that do change on different systems is
the IntPtr and UIntPtr types:

"The IntPtr type is designed to be an integer whose size is platform-specific. That is, an instance of this type is expected to
be 32-bits on 32-bit hardware and operating systems, and 64-bits on 64-bit hardware and operating systems."

HTH
LFS

Nov 21 '05 #10

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

Similar topics

5
2722
by: Dan Gidman | last post by:
Well guys this may be the wrong place but an earlier post by an "expert" about how a table was poorly designed has piqued my interest. The question is this. What are the do's and don'ts of sql development? Please list what you consider to be good and bad practices in general and/or specific or list links to resources that would be...
0
7464
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7396
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...
0
7656
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. ...
0
7805
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5968
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...
1
5323
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...
0
3449
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...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
700
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.