<h2>PHP, 51 characters</h2> function f($n){return(int)$n>$n?(int)$n-1:(int)$n;} This should be able to be applied to most languages that do not support the n%1 trick.