无符号与符号数为指标符号、数为、指标

2023-09-04 08:10:18 作者:☆沉睡☆千年的寂寞

请告诉我,使用符号数为指标的净道理呢?

Whats the rationale for using signed numbers as indexes in .Net?

在Python中,你可以从指数的阵列发送负数的结束,但这不是在.NET中的情况。 这是不容易的净增加这样的功能之后,它可以打破可能使用特殊规则等code(是的,一个坏主意,但我想它发生)的索引。

In Python, you can index from the end of an array by sending negative numbers, but this is not the case in .Net. It's not easy for .Net to add such a feature later as it could break other code perhaps using special rules (yeah, a bad idea, but I guess it happens) on indexing.

不,我曾经也需要数组索引的面积都超过2,147,483,647,但我真的不明白,为什么他们选择有符号数。

Not that I have ever have needed to index arrays over 2,147,483,647 in size, but I really cannot understand why they choose signed numbers.

这可能是因为这是比较正常的使用有符号数在code?

Can it be because it's more normal to use signed numbers in code?

编辑:我刚刚发现这些链接:

I just found these links:

无符号的迭代的危险在C / C ++

符号字长度和索引

EDIT2:好的,一对夫妇从线程马修•富兰琛贴其他原因:

Ok, a couple of other good reasons from the thread Matthew Flaschen posted:

在历史的原因,因为它是一个类似C语言 在互操作使用C

推荐答案

有关课程的简单性。你喜欢麻烦做算术大小无符号整型?

For simplicity of course. Do you like trouble doing size arithmetic with unsigned ints?