C#/.NET: Difference between int and uint
Question by Guest | Last update on 2021-11-02 | Created on 2016-11-02
I know about the difference between the data types short, int and long (16-bit, 32-bit and 64-bit integer numbers) in C#. However, recently I have recognized some other integer types in an example code: ushort, uint and ulong - so that seems to be the normal types with an additional prepended u.
What are those types supposed to be? I have played a bit with them and they seem to work like usual integers. So, where is the difference?
Related Topics
MySQL: Add new Column to a Table
Tutorial | 0 Comments
C#/.NET: Difference between int and Int32
Question | 1 Answer
Delphi/Lazarus: Round Decimal Numbers up, down and normally
Tip | 0 Comments
Micro SD Memory Cards: Difference between microSD, microSDHC, microSDXC and microSDUC
Info | 12 Comments
MySQL: Integer Types
Info | 0 Comments
Java: Declare unsigned Integer
Question | 2 Answers
MySQL: Delete Data from Table - Difference between TRUNCATE, DELETE and DROP
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
The "u" is standing for "unsigned". So, those types are integers that don't have a sign and therefore can only hold positive values.
The advantage of those unsigned integers is that they can accept much higher numbers at the same bit length.
Here you can see the minimum and maximum values of the types:
As you can see, at the same bit length, the unsigned integers can take twice as large values. You should always use such types in a case in which you know that a value will never become negative but can become very large (and therefore can reach the limits of the available range).
Last update on 2021-11-02 | Created on 2016-11-03