floor¶
The floor filter rounds a numeric value down to the nearest integer. It is the opposite of the ceil filter and always returns the greatest integer less than or equal to the input value.
Functionality
- Numbers: Takes a numerical value as input (integer or floating-point).
- Rounding Down: Rounds the input number towards negative infinity, to the next whole number.
- Output: Returns a new integer value representing the rounded result.
Syntax
ArgumentsThe floor filter does not require any arguments.
Code Samples
Example 1: Rounding Down a Decimal
Output:
Example 2: No Change for IntegersOutput:
Example 3: Rounding Down a Negative DecimalOutput:
Outliers and Special Cases¶
- Non-Numeric Input: If the input is not a number (e.g., a string or boolean), the
floorfilter might attempt to convert it to a number before rounding. If the conversion fails, an error might be thrown.
Key Points¶
- The
floorfilter is a basic mathematical operation for rounding numbers within templates. - It is useful when you want to ensure a value does not exceed a certain integer threshold.
- Use cases include calculating maximum capacities, truncating timestamps, or any situation where you need to round down to the nearest whole number.
- Be aware of data types to prevent errors and ensure expected behavior.