What is type casting?
- changing the type of a variable's value temporarily to perform an operation
- the variable is unchanged after the operation and type casting
Why is type casting important?
- you don't need a separate variable to hold the same value but in a different type
- e.g.
variable_as_int = 1
andvariable_as_float = 1.0
- e.g.
- you can specify a data type that you need at the time of the operation, e.g. this gives you flexibility
How to type cast?
(new_type) expression
- e.g.
(float) some_integer
- read more at http://www.tutorialspoint.com/cprogramming/c_type_casting.htm
- read more at http://www.cprogramming.com/tutorial/c/lesson11.html