C convert floating point to int

I am using C (not C ++).

I need to convert a floating point number in int. I do not want to round to the nearest number, I just want to exclude what is after the integer part. Sort of

4.9 -> 4 .9 -> 4
+4
source share
2 answers
my_var = (int)my_var;

So simple. Basically you don't need this if the variable is int.

+13
source

Use in c

int C = var_in_float;

They transform implicit

thank

+3
source

Source: https://habr.com/ru/post/1548250/


All Articles