Introduction to Programming in C - part 8 - Casting - math/maths with int and double

preview_player
Показать описание
We look at casting in simple maths functions for integers and doubles here

If we have
int n1;
double angle;

then

(double) n1

converst n1 into a double

and

(int) angle

converts angle to an integer type. - note that in the conversion to an integer the computer removes everything after the decimal place - it will not automatically round to the nearest integer .... to round to the nearest integer we need to use (int) (angle+0.5)
Рекомендации по теме
visit shbcf.ru