I need to know how to convert a number of the type double to a number of the type int. My double numbers have a lot of digits behind the decimal point and I need to have these properly rounded(not a 'ceil' or 'floor' type of rounding) after the conversion has taken place. Is there a simple way to do this? What is the best way to do it? Below is some code that does not work.

Code:#include <stdio.h> #include <math.h> int main() { double x, y; int a, b; x = 3.322884; y = 3.700219; a = x; b = y; printf("a = %d, b = %d\n", a, b); }