uint和int之间的区别 [英] difference between uint and int

查看:470
本文介绍了uint和int之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi hi

i想知道int和uint之间有什么区别,两种数据类型都相同

我们可以用int替换uint吗

和Convert.ToUint32转换为.ToInt32 ??

解决方案

参考 - int和uint/long和ulong之间有什么区别? [ ^ ]。

引用:

int的限制(32位)是:

 int:-2147483648到2147483647 
uint:0到4294967295

Quote:

我们可以用int替换uint

是的,如果你没有负数来处理。


1。 uint 等价于 Uint32 - 表示无符号整数,只能正值;



2. int 等同于 Int32 -and是一个普通的整数类型也可以有负值



3.如果两个都是正值,你可以从一种类型转换为另一种类型从uint到int的情况,如果值不大于Int32的最大值。


http://stackoverflow.com/questions/3724242/what-is-the-difference-between-int-and-uint-long-and- ulong [ ^ ]





int(32位)的限制为:



  int  :-2147483648到 2147483647  



 uint: 0  4294967295  





和长(64位):



 : -   9223372036854775808  9223372036854775807  



 ulong: 0  18446744073709551615  


hi people
i want to know what is the difference between int and uint both the data types are same
and can we replace uint with int
and Convert.ToUint32 to Convert.ToInt32??

解决方案

Refer - What is the difference between "int" and "uint" / "long" and "ulong"?[^].

Quote:

The limits for int (32 bit) are:

int: –2147483648 to 2147483647 
uint: 0 to 4294967295

Quote:

can we replace uint with int

Yes, if you don't have negative numbers to deal with.


1. uint equivalent with Uint32 - means unsigned integer and can have only positive values;

2. int is equivalent with Int32 -and is a normal integer type can can have also negative values

3. You can convert from one type to other if both are positive values and in the case from uint to int if the value is not bigger then Maximum value for Int32.


http://stackoverflow.com/questions/3724242/what-is-the-difference-between-int-and-uint-long-and-ulong[^]


The limits for int (32 bit) are:

int: –2147483648 to 2147483647 


uint: 0 to 4294967295 



And for long (64 bit):

long: -9223372036854775808 to 9223372036854775807


ulong: 0 to 18446744073709551615


这篇关于uint和int之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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