MAINSAIL Language Manual, Section 35.13

previous   next   top   contents   index   framed top   this page unframed


35.13. floor

Figure 35–14. floor (GENERIC)
INTEGER
PROCEDURE   floor       (REAL x);

LONG INTEGER
PROCEDURE   floor       (LONG REAL x);

floor returns the largest (LONG) INTEGER less than or equal to x.

Example 35–15. Use of floor
floor(10.5)  = 10
floor(-10.5) = -11

Figure 35–16 shows the directions on the real number line in which the conversion PROCEDUREs from (LONG) REAL to (LONG) INTEGER “move” their arguments (there is no movement if the argument is an integral value).

Figure 35–16. Rounding Directions for (LONG) REAL to (LONG) INTEGER Conversion PROCEDUREs

floor         <------       |       <------
                            |
ceiling       ------>       |       ------>
                            |
truncate      ------>       |       <------
                            |
cvi/cvli      <----->       |       <----->
                            |
----------------------------+----------------------------
             negative       0       positive

floor(-10.5)    = -11         floor(10.5)    = 10
ceiling(-10.5)  = -10         ceiling(10.5)  = 11
truncate(-10.5) = -10         truncate(10.5) = 10
cvi(-10.4)      = -10         cvi(10.4)      = 10
cvi(-10.6)      = -11         cvi(10.6)      = 11

The values of cvi(-10.5) and cvi(10.5) are unspecified; they may be -10 or -11, and 10 or 11, respectively.


previous   next   top   contents   index   framed top   this page unframed

MAINSAIL Language Manual, Section 35.13