Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Int64 and UInt64 are of same size

Tags:

c#

.net

I'm asking in context of C#. Why both Int64 and UInt64 are of same size i.e. 64-bits. Same goes to other Int variables also.

I was expecting UInt to be smaller in size at least a bit as it do not need to represent the - sign, am I expecting some illogical thing here?

like image 258
yogi Avatar asked Dec 18 '25 17:12

yogi


1 Answers

The 64 in Int64 and UInt64 means the size of the integer is 64 bits. That's why they are the same size.

The size is the same, but range is different (also due to the significant bit):

  • UInt64: 0 to 18,446,744,073,709,551,615;
  • Int64: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
like image 116
Patrick Hofman Avatar answered Dec 20 '25 07:12

Patrick Hofman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!