Updated the floor function

Now the function uses a template to convert to a certain numerical
type in the return value. When the result has an unsigned integral
type the input must be nonnegative.
Remove unnecessary extra code
Correspondingly update ceil and trunc