ASP. C # int type has no change in the range of values in 32/64-bit environment

Source: Internet
Author: User

Recently in the study suddenly thought, I in 64-bit environment, int value range has changed? To test this result, I did the following:
1, Environment: Win7 flagship 64-bit +VS2010 SP1 (version number: 10.0.40219.1sp1rel) +.net 4.0.30319 Sp1rel
2. Code:

Code to copy code as follows
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 value of "long": "+ Long.) Maxvalue.tostring ());
Console.WriteLine (maximum value for "ULONG type:" + ulong.) Maxvalue.tostring ());
Console.readkey ();

}
}
}

As can be seen, the program ConsoleApplication1.exe has been running in 64-bit state (not 64-bit *32 tag), but the int is still 2.1 billion (decimal does not count ^q^)
So, int in 64-bit environment, more than 2.1 billion will overflow
Other than that. NET Int64 and C # Long, the value is the same.


The difference between C # int Int32 Int64
The Int16 value type represents a signed integer value between 32768 and +32767.

The Int32 value type represents a signed integer value between -2,147 (Www.111cn.net) and 483,648 to +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 Type
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 Type
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 Type
Long
9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Signed 64-bit integer
System.Int64

From:http://www.111cn.net/net/160/41798.htm

ASP. C # int type has no change in the range of values in 32/64-bit environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.