整数做与不做 [英] Integer Do's And Don'ts

查看:55
本文介绍了整数做与不做的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

声明整数时,可以使用int16,

int32或int64指定大小,普通整数为int32。


是整数编程社区中接受的默认值?


如果是这样的话,有没有办法从我自己的类型中自动删除类型中预定义大小的那些声明什么?

-

给我发电子邮件,ROT13我的电子邮件地址

解决方案




我不认为你可以从下拉列表中删除它们。最好的选择是

使用简单的整数。这将确保您使用的是32位

整数,现在它是最快的,因为它在32位编程模型中使用32位

边界。如果你打算将它们混合起来,那么请记住在你的代码顶部放置Option Strict On

页面。在计算和分配中转换它们时,这将节省您的头痛。祝好运! Ken。


-

Ken Dopierala Jr.

对于优秀的ASP.Net网站托管尝试:
< a rel =nofollowhref =http://www.webhost4life.com/default.asp?refid=Spinlighttarget =_ blank> http://www.webhost4life.com/default.asp?refid=Spinlight

如果您在我这里注册并需要帮助,请给我发电子邮件。


" John Baker" < WB ******** @ wzwfreivprf.pbz>在消息中写道

新闻:Sy ***************** @ fe1.columbus.rr.com ...

声明整数时,可以使用int16,
int32或int64指定大小,普通整数为int32。

整数是编程社区中接受的默认值?

如果是这样的话,有什么方法可以在我宣布某些内容时从类型自动排列中删除预定义大小的那些吗?
-
给我发电子邮件,ROT13我的显示的电子邮件地址



有一次我得到的结论是Integer是一个通用术语,它将
映射到本机整数你正在运行的环境的大小。

还有某种保证,它不会小于

Int32。如果你不需要特定尺寸,这将确保你获得最佳性能。

将来,Integer可能会映射到Int64,Long可能会映射到Int128,或者

无论如何。


但是,我也读了很多反对这句话的说法整数

将始终映射到Int32 。第一个论点对我来说更有意义,但我确实不知道未来的计划。


但为了安全起见,这里是什么我这样做。

如果我需要的是至少大小为Int32的通用整数,那么只需使用

Integer关键字,这几乎总是如此。

如果我正在处理比特字段或从文件读取数据块的事情

我知道是特定大小,那么我明确声明整数大小。


Gerald


" John Baker" < WB ******** @ wzwfreivprf.pbz>在消息中写道

新闻:Sy ***************** @ fe1.columbus.rr.com ...

声明整数时,可以使用int16,
int32或int64指定大小,普通整数为int32。

整数是编程社区中接受的默认值?

如果是这样的话,有什么方法可以在我宣布某些内容时从类型自动排列中删除预定义大小的那些吗?
-
给我发电子邮件,ROT13我的显示的电子邮件地址



" John Baker" < WB ******** @ wzwfreivprf.pbz> schrieb:

声明一个整数时,可以使用int16,
int32或int64指定大小,普通整数为int32。

是整数在编程社区中接受默认值?


对于在类型名称中优先使用别名

的问题,有不同的立场,因为它们可以在.NET Framework中找到。


就个人而言,我使用''Integer'',''Short'',...当我写完全管理

代码。当与非托管代码进行互操作时,我更喜欢更低级别的
名称,''Int32'',''Int16'',...

如果是这样,是有什么方法可以在我声明某些内容时从
自动类型中删除预定义大小的那些?




No.

-

Herfried K. Wagner [微软MVP]

< URL:http://dotnet.mvps.org/>


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

解决方案

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********@wzwfreivprf.pbz> wrote in message
news:Sy*****************@fe1.columbus.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



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********@wzwfreivprf.pbz> wrote in message
news:Sy*****************@fe1.columbus.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



"John Baker" <wb********@wzwfreivprf.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/>


这篇关于整数做与不做的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆