floor() : Round Down to Integer
On this page
Summary
Round a number down to the nearest integer.
Signature
floor(value)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value |
Number | Yes | The number to round down |
Returns
Type: Integer
The largest integer less than or equal to the value.
Examples
Round Down Prices
Data:
doc.Params["model"] = new {
price = 19.99m
};
Output:
<p>Base Price: $19</p>
Calculate Completed Items
Data:
doc.Params["model"] = new {
items = 47,
setSize = 10
};
Output:
<p>Full sets: 4</p>
Age Calculation
Data:
doc.Params["model"] = new {
days = 10950
};
Output:
<p>Age: 30 years</p>
Always Round Down
Data:
doc.Params["model"] = new {
values = new[] { 1.1, 2.5, 3.9, 4.0 }
};
Output:
<li>1.1 → 1</li>
<li>2.5 → 2</li>
<li>3.9 → 3</li>
<li>4.0 → 4</li>
Notes
- Always rounds down (towards negative infinity)
- Returns integer type
- For up rounding, use
ceiling() - For nearest rounding, use
round() - For removing decimals without rounding, use
truncate() - Negative numbers round away from zero:
-1.5→-2