Sunday, November 7, 2010

Learn c# easily lesson 5

                                           

view previous lesson4      

     Integral Types

In C#, an integral is a category of types. For anyone confused because the word Integral sounds like a mathematical term, from the perspective of C# programming, these are actually defined as Integral types in the C# programming language specification. They are whole numbers, either signed or unsigned, and the char type. The char type is a Unicode character, as defined by the Unicode Standard. For more information, visit The Unicode Home Page. table 2-1 shows the integral types, their size, and range.
Table 2-1. The Size and Range of C# Integral Types
TypeSize (in bits)Range
sbyte8-128 to 127
byte80 to 255
short16-32768 to 32767
ushort160 to 65535
int32-2147483648 to 2147483647
uint320 to 4294967295
long64-9223372036854775808 to 9223372036854775807
ulong640 to 18446744073709551615
char160 to 65535
Integral types are well suited for those operations involving whole number calculations. The char type is the exception, representing a single Unicode character. As you can see from the table above, you have a wide range of options to choose from, depending on your requirements.

Floating Point and Decimal Types

A C# floating point type is either a float or double. They are used any time you need to represent a real number, as defined by IEEE 754. For more information on IEEE 754, visit the IEEE Web Site. Decimal types should be used when representing financial or money values. table 2-2 shows the floating point and decimal types, their size, precision, and range.
Table 2-2. The Floating Point and Decimal Types with Size, precision, and Range
TypeSize (in bits)precisionRange
float327 digits1.5 x 10-45 to 3.4 x 1038
double6415-16 digits5.0 x 10-324 to 1.7 x 10308
decimal12828-29 decimal places1.0 x 10-28 to 7.9 x 1028
Floating point types are used when you need to perform operations requiring fractional representations. However, for financial calculations, the decimal type is the best choice because you can avoid rounding errors.


1 comment:

  1. This is a really informative knowledge, Thanks for posting this informative Information. Covid-19 Cleaning Services Ridley Park

    ReplyDelete