minus¶
The minus filter subtracts a specified number from the input number. It is a fundamental arithmetic operation for calculations within your templates.
Functionality
- Numbers: Takes a numerical value as input (integer or floating-point).
- Subtrahend: Requires a numerical argument specifying the number to subtract.
- Subtraction: Subtracts the second number (the subtrahend) from the first number (the input).
- Output: Returns a new numerical value representing the result of the subtraction.
Syntax
Arguments- subtrahend: The numerical value to subtract from the input number.
Code Samples
Example 1: Subtracting a Positive Number
Output: Example 2: Subtracting a Negative NumberOutput:
Example 3: Subtracting Decimals Output:Outliers and Special Cases¶
- Non-Numeric Input: If the input or the subtrahend is not a number (e.g., a string), the filter might attempt to convert it to a number. If the conversion fails, an error might be thrown.
Key Points¶
- The
minusfilter is a basic but essential arithmetic operation for working with numbers in templates. - It is useful for calculating differences, discounts, or any scenario where you need to subtract one value from another.
- Pay attention to the order of the values: the
subtrahendis subtracted from theinput_number. - Be mindful of data types to ensure correct behavior and avoid errors.