--- warning: This file is auto generated by `yarn web:inject`, do not edit by hand examples: - floor(4.7) - floor(-0.5) - floor(3) returns: - '4' - '-1' - '3' dependencies: [] authors: original by: - Kevin van Zonneveld (https://kvz.io) notes: - Returns the largest integer <= x parityVerified: - Lua 5.4 isTypescript: true type: function layout: function title: Lua's math.floor in TypeScript description: >- Here's what our current TypeScript equivalent to Lua's math.floor looks like. function: floor category: math language: lua permalink: lua/math/floor/ alias: - /functions/lua/floor/ - /functions/math/floor/ - /lua/floor/ ---
{% codeblock lang:typescript %}export function floor(x: number): number { // discuss at: https://locutus.io/lua/floor/ // parity verified: Lua 5.4 // original by: Kevin van Zonneveld (https://kvz.io) // note 1: Returns the largest integer <= x // example 1: floor(4.7) // returns 1: 4 // example 2: floor(-0.5) // returns 2: -1 // example 3: floor(3) // returns 3: 3 return Math.floor(x) } {% endcodeblock %}