PICO-8 Wiki
Advertisement
flr( num )
Returns the integer portion (the "floor") of a number.
num
The number.

For positive numbers, the flr() function returns the integer portion of a number, such as 5 for 5.8.

More generally, flr() returns the closest integer to the number that is less than the number. For negative numbers, the result is more negative.

Examples

print(flr(5.9))   -- 5

print(flr(-5.2))  -- -6

print(flr(7))     -- 7

print(flr(-7))    -- -7

Pico-8 does not have a corresponding "ceiling" function. Here is an implementation that uses flr():

function ceil(num)
  return flr(num+0x0.ffff)
end

print(ceil(5.9))   -- 6

print(ceil(-5.2))  -- -5

print(ceil(7))     -- 7

print(ceil(-7))    -- -7

See also

Advertisement