Use the right free function.
Handle non-finite numbers in ceil and floor.