Search code examples
cintegerdoublerounding

How to round down a double to the nearest smaller int in C?


I've got a double:

double d = 25.342;

How can I convert it to 25?

If it were -12.46 I'd like to get -13.


Solution

  • int i = (int)floor(25.342);