Before you get into casting, you need to be clear about the meaning of types. As an example take the integer and unsigned integer. Take an 8-bit variety in this example:
The signed integer has a range of: −128 to +127. The unsigned integer has a range of: 0 to +255. You can see that the unsigned integer is only for positive numbers. Take for example a "cruise control" program in a car. You never have a negative speed so a "signed" integer is inappropriate. Where this can lead (and does) to trouble is like this: Unsigned Int a Signed Int b Get a and b from somewhere: While (b is less than a) do something. You can see the problem I'm sure because "b" can only reach 127 so potentially, this number might always be less than a even if the "facts" are different. Casting is turning one type into another and as you can see, there is a potential problem with the "real" value. --- In [email protected], "zeb_zxc" <zeb_...@...> wrote: > > it is very difficult to understand the casting(data type conversion)can any > body help me in understanding the casting >
