473,839 Members | 1,361 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 3402
Jay,

<...>
I would expect P/Invoke to be largely agnostic also <...> In other words I can understand platform = 32bit or 64bit or Any, I just
haven't seen the explanation on why both x64 & Itanium...
Ah, good point. That is supposed to be the beauty of .Net in the first
place! I'll keep my eyes open for some sort of better explanation. Might be
interesting. Got out of the server business shortly before the buzz of x64.
Didn't sell many Itanium servers. Customers would buy like 4-32bit Linux
boxes and got better overall throughput for a whole LOT less money.

You have the 80/20 rule mapped to a AutoText or something? ;-)
But it is spot on and worth repeating.
Haven't looked at the Beta stuff yet. Maybe I should get up to speed.

Gerald
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:OV******** *****@TK2MSFTNG P09.phx.gbl... Gerald,
I haven't paid much attention to the x64 vs Itanium stuff. But as I
understand it, the x64 is kind of a hybrid processor. It has the 32 Bit
instructions as well as the 64 Bit instructions. I believe you may be correct. However! VB.NET & C# compiles down to IL, IL
is platform agnostic. As far as I know the only real reason you need to

know the platform is P/Invoke (the marshaller needs to know how to package the
parameters).

I would expect P/Invoke to be largely agnostic also, in that its just a
Thunk to the real API. In other words the JIT &
System.Runtime. InteroprService s class resolve any calling convention
differences, the IL is an abstraction that shouldn't care if you are a
hybrid process or not...

In other words I can understand platform = 32bit or 64bit or Any, I just
haven't seen the explanation on why both x64 & Itanium...
Gotta watch out how much memory we consume. Just Remember the 80/20 rule. That is 80% of the execution time of your
program is spent in 20% of your code. I will optimize (worry about
performance, memory consumption) the 20% once that 20% has been identified

& proven to be a performance problem via profiling (CLR Profiler is one
profiling tool).

For info on the 80/20 rule & optimizing only the 20% see Martin Fowler's
article "Yet Another Optimization Article" at
http://martinfowler.com/ieeeSoftware...timization.pdf
Would be a shame to waste half of it due to unneccessary boxing. Unnecessary boxing can be a bad idea even in the 32-bit world! Which is

why the new Generic collection classes
(http://msdn2.microsoft.com/library/0sbxh9x2.aspx) will be very handy
indeed. I normally try to apply the 80/20 rule on deciding if I want to use an array of value types or an Arraylist of value types. With .NET 2.0 & the Generic collection classes I may simply favor the Generic collection
classes, unless they, via profiling are shown to be a performance issue for a specific routine...

Hope this helps
Jay


"Gerald Hernandez" <Cablewizard@sp *********@Yahoo .com> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
Thanks, that is a good read.
While I hadn't really considered Integer being Int64 on 64 bit processors in
the near future, it does look like there are some things to consider. It
does look like 2 Int32's will be packed nicely into an Int64, which we all would expect now. This is a nice change from past platform differences
where
a whole Int64 might be allocated for 1 Int32. Guess we need to be aware of the size of the pointers, which we also knew, but looks like it could
raise
it's head in unexpected ways. Gotta watch out how much memory we consume. Would be a shame to waste half of it due to unneccessary boxing.

I haven't paid much attention to the x64 vs Itanium stuff. But as I
understand it, the x64 is kind of a hybrid processor. It has the 32 Bit
instructions as well as the 64 Bit instructions. Also supports both memory pipelines. The Itanium has it's own set of 64 Bit instructions, and only
those. So in the long run it looks like it might die due to compatibility issues.

Gerald

<<snip>>

Nov 21 '05 #61
Reply to earlier topic on this thread:
IL contains a native int type which is surfaced in managed languages as
System.IntPtr; that type has integer semantics and will be 8-bytes on a
64-bit machine and 4-bytes on a 32-bit machine (IntPtr.Size is a static
property which can be used to cheaply determine bitness programatically ).

As for why there are X64 and Itanium options?
An answer (not the only one, but a good one) is P/Invoke. If you're
P/Invoke-ing out to a OS provided DLL you can be pretty sure that it will
exist on both IA64 and X64 platforms... But, if you have some native code
from somewhere else that you need to P/Invoke to and you want to ship it with
your product say; then you need to make sure to include both IA64 and X64
versions if you want your app to run on both platforms. What if the vendor
who wrote the component didn't provide both versions, or didn't bother
compiling both versions (it is worth noting that native IA64 code is
significantly harder to write than X64 code, and there isn't nearly as much
IA64 penetration in the marketplace as there will be with both AMD and Intel
X64 systems now out)?

Thus we allow you to bind your app to a single 64-bit platform. If you
compile your app with /platform:anycpu then it will run under 64-bits on a
64-bit machine which is more or less what you want. The only case I can
imagine where you might want a more generic 64-bit only marking would be for
unsafe code that is compiled to be 64-bit specific (but not platform
specifc)... In that case most of the bitness specific code is around pointer
sizes and using proper pointer types in C# will let you avoid that... I don't
even think that you can use straight pointers in VB so the point is moot.
Even so, you could concievably write your code with an if (IntPtr.Size == 4)
{ /* 32-bit code */ } else { /* 64-bit code */ }. As IntPtr.Size is a static
property which is hardcoded by the runtime to be 4 or 8 depending on the
platform a smart JIT (which I believe ours to be) should be able to inline it
and use its dead code eliminator to throw away the non-executed half of the
conditional as well as the conditional statement itself.


"Jay B. Harlow [MVP - Outlook]" wrote:
Gerald,
I haven't paid much attention to the x64 vs Itanium stuff. But as I
understand it, the x64 is kind of a hybrid processor. It has the 32 Bit
instructions as well as the 64 Bit instructions.

I believe you may be correct. However! VB.NET & C# compiles down to IL, IL
is platform agnostic. As far as I know the only real reason you need to know
the platform is P/Invoke (the marshaller needs to know how to package the
parameters).

I would expect P/Invoke to be largely agnostic also, in that its just a
Thunk to the real API. In other words the JIT &
System.Runtime. InteroprService s class resolve any calling convention
differences, the IL is an abstraction that shouldn't care if you are a
hybrid process or not...

In other words I can understand platform = 32bit or 64bit or Any, I just
haven't seen the explanation on why both x64 & Itanium...
Gotta watch out how much memory we consume.

Just Remember the 80/20 rule. That is 80% of the execution time of your
program is spent in 20% of your code. I will optimize (worry about
performance, memory consumption) the 20% once that 20% has been identified &
proven to be a performance problem via profiling (CLR Profiler is one
profiling tool).

For info on the 80/20 rule & optimizing only the 20% see Martin Fowler's
article "Yet Another Optimization Article" at
http://martinfowler.com/ieeeSoftware...timization.pdf
Would be a shame to waste half of it due to unneccessary boxing.

Unnecessary boxing can be a bad idea even in the 32-bit world! Which is why
the new Generic collection classes
(http://msdn2.microsoft.com/library/0sbxh9x2.aspx) will be very handy
indeed. I normally try to apply the 80/20 rule on deciding if I want to use
an array of value types or an Arraylist of value types. With .NET 2.0 & the
Generic collection classes I may simply favor the Generic collection
classes, unless they, via profiling are shown to be a performance issue for
a specific routine...

Hope this helps
Jay


"Gerald Hernandez" <Cablewizard@sp *********@Yahoo .com> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
Thanks, that is a good read.
While I hadn't really considered Integer being Int64 on 64 bit processors
in
the near future, it does look like there are some things to consider. It
does look like 2 Int32's will be packed nicely into an Int64, which we all
would expect now. This is a nice change from past platform differences
where
a whole Int64 might be allocated for 1 Int32. Guess we need to be aware of
the size of the pointers, which we also knew, but looks like it could
raise
it's head in unexpected ways. Gotta watch out how much memory we consume.
Would be a shame to waste half of it due to unneccessary boxing.

I haven't paid much attention to the x64 vs Itanium stuff. But as I
understand it, the x64 is kind of a hybrid processor. It has the 32 Bit
instructions as well as the 64 Bit instructions. Also supports both memory
pipelines. The Itanium has it's own set of 64 Bit instructions, and only
those. So in the long run it looks like it might die due to compatibility
issues.

Gerald

<<snip>>

Nov 21 '05 #62

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

Similar topics

5
2734
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
9855
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 usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9697
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
10909
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
10588
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
10650
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
10295
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...
0
5682
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4065
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3136
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.