Q21. What are the potential problems in type conversions?
Ans. Assigning a value to a type with a greater range (for example, from short to long) poses no problem, however, assigning a value of larger data type to a smaller data type (for example, form double to float) may result in losing some precision.
There are some other similar potential conversion problems that are listed below:
|1.||Bigger floating-point type to smaller floating-point type (for example, double to float)||Loss of precision (significant figures). Original value may be out of range for target type, in which case result is undefined.|
|2.||Floating-point type to integer type||Loss of fractional part. Original value may be out of range for target type, in which case result is undefined.|
|3.||Bigger integer type to smaller integer type (for example, long to short)||Original value may be out of range for target type. Typically, just resulting in loss of information.|