Recently in the study, I suddenly thought, I in 64-bit environment, int range of values have changed? To detect this result, I did the following test:
1, Environment: Win7 flagship 64-bit +VS2010 SP1 (version number: 10.0.40219.1sp1rel) +.net 4.0.30319 Sp1rel
2, Code:
The code is as follows |
Copy Code |
Using System; Using System.Collections.Generic; Using System.Linq; Using System.Text; Namespace ConsoleApplication1 { Class Program { static void Main (string[] args) { Console.WriteLine ("Maximum value of type int:" +int.) MaxValue); Console.WriteLine ("Maximum value of Int64 type:" + int64.maxvalue); Console.WriteLine ("Maximum of type long:" + long.) Maxvalue.tostring ()); Console.WriteLine ("Maximum value of ulong type:" + ulong.) Maxvalue.tostring ()); Console.readkey ();
} } } |
As can be seen from the screenshot, the program ConsoleApplication1.exe has been running in 64-bit state (not 64-bit with *32), but the int is still 2.1 billion (decimal is not counted ^q^)
So, int in 64-bit environment, more than 2.1 billion or will overflow
Other than that. NET and the Int64 of C #, the values are the same.
The difference between C # int Int32 Int64
Int16 value types represent signed integers with values between 32768 and +32767.
Int32 value types represent signed integers with values between 2,147,483,648 and +2,147,483,647.
The Int64 value type represents an integer value between 9,223,372,036,854,775,808 and +9,223,372,036,854,775,807.
--------------------------------------------------------------------------------------------------------------- -------------
The short keyword represents an integer data type that stores values based on the size and range shown in the following table.
type |
Range |
size |
. NET Framework Types |
Short |
-32,768 to 32,767 |
Signed 16-bit integer |
System.Int16 |
--------------------------------------------------------------------------------------------------------------- -------------
The int keyword represents an integral type that stores values based on the size and range shown in the following table.
type |
Range |
size |
. NET Framework Types |
Int |
-2,147,483,648 to 2,147,483,647 |
Signed 32-bit integer |
System.Int32 |
--------------------------------------------------------------------------------------------------------------- -------------
The long keyword represents an integral type that stores values based on the size and range shown in the following table.
type |
Range |
size |
. NET Framework Types |
Long |
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
Signed 64-bit integer |
System.Int64 |