473,837 Members | 1,624 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
61 3401
Hi Herfried,
Nope. 'Integer' always maps to 'System.Int32'. That's documented here:


For the current Net version, nothing is said that the Integer will not
called in a computer with a 64bit register to that which is than a Int64

And because it is not done you will never find any open documentation from
Microsoft on that.

Cor
Nov 21 '05 #11
"Cor Ligthert" <no************ @planet.nl> schrieb:
Nope. 'Integer' always maps to 'System.Int32'. That's
documented here:


For the current Net version, nothing is said that the Integer will not
called in a computer with a 64bit register to that which is than a Int64


Even on 64-bit systems, 'Integer' will be an alias for 'Int32'. Otherwise
the same confision caused with the transition from VB6 to VB.NET 2002 would
resurrect...

<URL:http://groups.google.de/groups?selm=...2MSFTNGP12.phx
..gbl>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #12
Larry,
Consequently, Integer is currently the most efficient data type in Visual
Basic .NET.

Yes, did you see that text on the link I showed you? It would be different
when if Net could work on 8088 or 8086 computers.

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:
Are you sure of that in a 8088 the register holds only 8 bits words and on
the 8086 it was 16 bits. Therefore the Int16 should be the best type on the
8086.

On currenct computer which run Microsoft Net it is 32 bits, so any other
format needs extra processing. (Not talking about 64bits see for that
beneath)

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."


See this for the Int64
http://msdn.microsoft.com/library/de...classtopic.asp

I am talking how the processor acts with it on a 64bits computer will any
64bit format be the most efficient and I assume that future VSNet will
optimize for that when the Integer is used.

Cor

Nov 21 '05 #13
Hi Herfried,
For the current Net version, nothing is said that the Integer will not
called in a computer with a 64bit register to that which is than a Int64


Even on 64-bit systems, 'Integer' will be an alias for 'Int32'. Otherwise
the same confision caused with the transition from VB6 to VB.NET 2002
would
resurrect...


Than there would not be a need to call it Integer and is Int32 sufficient
and be a big stuppidity of Microsoft, I think they are not.

In most good compilers there where always option settings to exclude older
processor types and with that optimize the code, I assume that this will be
with this as well in future.

Cor
Nov 21 '05 #14

"Cor Ligthert" <no************ @planet.nl> wrote
Yes, did you see that text on the link I showed you? It would be different
when if Net could work on 8088 or 8086 computers.
No, it would not be different.

But that does not say what you indicated,

Are you sure of that in a 8088 the register holds only 8 bits words and on
the 8086 it was 16 bits. Therefore the Int16 should be the best type on the
8086.
Correct, but if VB.Net was running on that 8086, an Integer would still be 32 bits.

See this for the Int64
http://msdn.microsoft.com/library/de...classtopic.asp
Did you see this:

"Represents a 64-bit signed integer."
The size of a bit will not change, and Int64 uses 64 of them, that will not
change, it says so, at the very top of the document, an Int64 is a 64-bit
signed integer. 64 bits now, and 64 bits later.... Now go look at Integer!

http://msdn.microsoft.com/library/en...datInteger.asp

"Integer variables are stored as signed 32-bit (4-byte) integers"

It says Integer uses 32 bits. It does not say is uses the best size
for the platform, it uses 32 bits. A bit will not change, and it uses 32
of them.

I am talking how the processor acts with it on a 64bits computer will any
64bit format be the most efficient and I assume that future VSNet will
optimize for that when the Integer is used.


No, Integer will be 32 bits on a 64 bit system.

Imagine, if Integer moved to 64 bits, what will Long be? And if
Long moves to 128 bits does that mean a Byte type should move too?

The bit sizes are fixed on all but two types (IntPtr, IntPtr).

(Read those in Help...)
LFS

Nov 21 '05 #15
Larry,

Correct, but if VB.Net was running on that 8086, an Integer would still be
32 bits.


Why are you some defintive in this, do you have some documentation I do not
have?

You show me a page where it is even written that the value of an Integer in
VB6 was 16bits (based on 16bits register most probably what was in past
needed, however not now because Microsoft Net is not running on 16bit
computers)

Where do I not understand you.

This page shows what I am telling in this thread. And still you say that
Integer is a fixed word for Int32.

Cor
Nov 21 '05 #16
"Cor Ligthert" <no************ @planet.nl> schrieb:
Correct, but if VB.Net was running on that 8086, an Integer would still be 32 bits.
Why are you some defintive in this, do you have some documentation I do

not have?
It would be still 32-bit, with the same semantics of the 'System.Int32'
type, because it will be the same type.
You show me a page where it is even written that the value of an Integer in VB6 was 16bits (based on 16bits register most probably what was in past
needed, however not now because Microsoft Net is not running on 16bit
computers)
There was a lot of discussion about renaming the datatypes, and it was IMO a
bad idea to do that because it broke language stability. But that's another
topic. VB6 and VB.NET cannot be compared, and it's irrelevant what aliases
there are defined for a certain CTS type ('System.Int32' ). In C# it's
'int', in VB.NET it's 'Integer', independent from the processor/register
architecture of the system the application is running on.

I agree that there may be a negative impact when running an application that
makes extensive use of 'Integer' (= 'Int32') on an 8-bit machine, for
example. Nevertheless, this doesn't change anything with the 'Integer' (=
'Int32') data type.
This page shows what I am telling in this thread. And still you say that
Integer is a fixed word for Int32.


The page clearly says "Integer variables are stored as signed 32-bit
(4-byte) integers". It doesn't take account of the underlying
implementation that may store the value as 4 bytes in a 64-bit register.
Running a .NET application simply won't require any additional
considerations for a programmer who uses 'Integer', because 'Integer' will
still have its 32-bit integer semantics, and not 64-but integer semantics.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #17
JD
In the .NET type system there is no such type as "Integer", they are Int8,
Int16, Int32, Int64. Brad Abrams wrote its up to the specific language
implementation to map "Integer" to the specific integer size in the .NET
type system. VB specification clearly states that Integer will mapped to
Int32. Whether that changes or not is up to the language, not the .NET type
system.

JD

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:eM******** ********@TK2MSF TNGP14.phx.gbl. ..
Hi Herfried,
For the current Net version, nothing is said that the Integer will not
called in a computer with a 64bit register to that which is than a
Int64
Even on 64-bit systems, 'Integer' will be an alias for 'Int32'. Otherwise the same confision caused with the transition from VB6 to VB.NET 2002
would
resurrect...
Than there would not be a need to call it Integer and is Int32 sufficient
and be a big stuppidity of Microsoft, I think they are not.

In most good compilers there where always option settings to exclude older
processor types and with that optimize the code, I assume that this will

be with this as well in future.

Cor

Nov 21 '05 #18
"JD" <no@address.org > schrieb:
In the .NET type system there is no such type as "Integer", they are Int8,
Int16, Int32, Int64. Brad Abrams wrote its up to the specific language
implementation to map "Integer" to the specific integer size in the .NET
type system.
That's true.
VB specification clearly states that Integer will mapped to
Int32. Whether that changes or not is up to the language, not the .NET type system.


Changing a datatype's semantics will break existing code (see transition
from VB6 -> VB.NET). So it's very unlikely that the mapping 'Integer' ->
'Int32' will ever change in VB.NET, and there is absolutely no indication
that it will change in future.

The choice of a data type should /not/ be made with the processor
architecture and hardware features in mind, instead it should be made based
on the context of the programming problem that should be solved.

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

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

Correct, but if VB.Net was running on that 8086, an Integer would still be
32 bits.
Why are you some defintive in this, do you have some documentation I do not
have?


Did you not hear the large outcry when developers first learned that
..Net Integer would be 32 bits??? How many bits does a VB6 Byte have?
How many are there in VB.Net? What do you suppose would happen if
MSFT decided that a Byte in VB.Net now has 16 bits?

The data type names have been the same since version 1. Now in VB.Net
they changed the number of bits and developers did not like it. Why did
they not change the Byte type? Instead they added a new type in place
of VB6 Integers, a 2 byte Short. Why did they not change Byte to 16 bits?

The reason is because the name is supposd to identify the type of data that
the variable can hold. A Byte holds 0-255, a Short is 2 bytes, and an
Integer is 4 bytes. Is a byte going to change for 64 systems, - not very likely.

You show me a page where it is even written that the value of an Integer in
VB6 was 16bits
http://msdn.microsoft.com/library/en...rpDataType.asp

Where do I not understand you.

This page shows what I am telling in this thread. And still you say that
Integer is a fixed word for Int32.


I would like to say that, but I cant....
As we saw from VB6 to VB.Net, Microsoft can do whatever they want.
I am saying that _most developers_ expect Integer will remain fixed to an
Int32. No one can be sure what MSFT will decide to do....

Have you not noticed that (Microsoft specific) C++ names did not change
in the move from 16 to 32 bit systems? They will not change in size from
32 to 64 either. The names are associated with the size, that is what is expected.

While the C++ language specifies integral names, Microsoft has specific names
that do not change size on different systems. That is what developers expect
from VB. That is how it should be, but no one can say how it will be when
Microsoft can do whatever they feel is in their own best interest....

LFS
Nov 21 '05 #20

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

Similar topics

5
2733
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 considered under this topic. When I consider best practices myself of course there is always the...
0
9696
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
10902
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...
0
10583
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10642
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
10288
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...
1
7824
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...
1
4481
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
4062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3128
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.