//Pseudocode
If(floor(x) / 2 != 0) //If the number is an odd decimal.
{
answer = floor(x); //The answer is that number.
}
else //Otherwise
{
answer = ceil(x); //Closest odd number is going to be above.
}
You might want to add code to check for even integers, as these are equidistant, but will be thrown by this program into the else{} case.
floor(n) - Rounds down a number.
ceil(n) - Round up a number.