C convert floating point to int

c, casting, floating-point, int, type-conversion

Solution

my_var = (int)my_var;

As simple as that. Basically you don't need it if the variable is int.

Problem

I'm using C (not C++). I need to convert a float number into an `int`. I do not want to round to the the nearest number, I simply want to eliminate what is after the integer part. Something like ``` 4.9 -> 4.9 -> 4 ```

Original source

Related problems