The ceiling function ceil(x) returns the smallest integer greater than or equal to x. For -4.5, the integers greater than -4.5 are -4, -3, -2, etc. The smallest of these is -4, so ceil(-4.5) = -4. This is a common source of confusion with negative numbers.