13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>C#</strong> LANGUAGE SPECIFICATION• The byte type represents unsigned 8-bit integers with values between 0 and 255.• The short type represents signed 16-bit integers with values between –32768 and 32767.• The ushort type represents unsigned 16-bit integers with values between 0 and 65535.• The int type represents signed 32-bit integers with values between –2147483648 and 2147483647.• The uint type represents unsigned 32-bit integers with values between 0 and 4294967295.• The long type represents signed 64-bit integers with values between –9223372036854775808 and9223372036854775807.• The ulong type represents unsigned 64-bit integers with values between 0 and18446744073709551615.• The char type represents unsigned 16-bit integers with values between 0 and 65535. The set of possiblevalues for the char type corresponds to the Unicode character set. [Note: Although char has the samerepresentation as ushort, not all operations permitted on one type are permitted on the other. end note]The integral-type unary and binary operators always operate with signed 32-bit precision, unsigned 32-bitprecision, signed 64-bit precision, or unsigned 64-bit precision:• For the unary + and ~ operators, the operand is converted to type T, where T is the first of int, uint,long, and ulong that can fully represent all possible values of the operand. The operation is thenperformed using the precision of type T, and the type of the result is T.• For the unary – operator, the operand is converted to type T, where T is the first of int and long thatcan fully represent all possible values of the operand. The operation is then performed using theprecision of type T, and the type of the result is T. The unary – operator cannot be applied to operands oftype ulong.• For the binary +, –, *, /, %, &, ^, |, ==, !=, >, =, and operators, the left operand is converted to type T, where T is the first of int,uint, long, and ulong that can fully represent all possible values of the operand. The operation is thenperformed using the precision of type T, and the type of the result is T.The char type is classified as an integral type, but it differs from the other integral types in two ways:• There are no implicit conversions from other types to the char type. In particular, even though thesbyte, byte, and ushort types have ranges of values that are fully representable using the char type,implicit conversions from sbyte, byte, or ushort to char do not exist.• Constants of the char type must be written as character-literals or as integer-literals in combinationwith a cast to type char. [Example: For example, (char)10 is the same as '\x000A'. end example]The checked and unchecked operators and statements are used to control overflow checking for integraltypearithmetic operations and conversions (§14.5.12). In a checked context, an overflow produces acompile-time error or causes an System.OverflowException to be thrown. In an unchecked context,overflows are ignored and any high-order bits that do not fit in the destination type are discarded.11.1.5 Floating point types<strong>C#</strong> supports two floating-point types: float and double. The float and double types are representedusing the 32-bit single-precision and 64-bit double-precision IEC 60559 formats, which provide thefollowing sets of values:92

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!