Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
CEILING()
, FLOOR()
These two functions have nothing to do with architecture, despite their names. They implement the mathematical concept of ceiling and floor, traditionally written with the symbols “é” and “ë”. The ceiling of a number is the next integer greater than or equal to the number, while the floor is the next integer less than or equal to the number. So, the ceiling or floor of an integer is the number itself. CEILING()
and FLOOR()
work on all the numeric types.
nResult = CEILING( nValue )
nResult = FLOOR( nValue )
Be careful when applying these functions to negative numbers. You may find the results a little counter-intuitive. For positive numbers, FLOOR()
and INT()
are the same. For negative numbers, CEILING()
and INT()
are the same. CEILING()
and FLOOR()
both return .NULL. when handed a null value.
? CEILING(3.14159) && 4
? FLOOR(3.14159) && 3
? CEILING(-17.385) && -17
? FLOOR(-17.385) && -18