Floor Division
systemic:core-fdivMathInputs
| Name | Type | Description |
|---|---|---|
| First Value | Number series | The value to be divided (the dividend). |
| Second Value | Number series | The value to divide by (the divisor). |
Outputs
| Name | Type | Description |
|---|---|---|
| Quotient | Number series | The whole-number result of the floor division for each bar. |
Cost
7
credits per run
1,000
bars
0.199 + 0.00608·n credits for n bars, rounded up. The marks are each plan's limit of bars.
Floor Division divides two values and rounds the result down to a whole number, always toward negative infinity.
The Formula
Where:
- = First Value (numerator)
- = Second Value (denominator)
- = Floor function (round down toward −∞)
Floor vs. Regular Division
| Expression | Regular Division | Floor Division |
|---|---|---|
| 7 ÷ 3 | 2.333... | 2 |
| 10 ÷ 4 | 2.5 | 2 |
| −7 ÷ 3 | −2.333... | −3 |
| −10 ÷ −4 | 2.5 | 2 |
Key insight: Floor division rounds toward negative infinity, not toward zero. So −7 ÷ 3 = −3 (not −2).
Worked Example
Calculating how many complete lots fit into the available capital:
| Available Capital | Lot Size | Floor Division | Interpretation |
|---|---|---|---|
| 10,000 | 3,000 | 3 | 3 complete lots |
| 10,000 | 4,000 | 2 | 2 complete lots |
| 10,000 | 7,000 | 1 | 1 complete lot |
| 5,500 | 2,000 | 2 | 2 complete lots (remainder 1,500) |
Practical Applications
1. Lot Sizing and Position Calculation
To calculate how many whole shares or contracts a given capital covers:
Position Size = Floor(Capital Available ÷ Price per Unit)
The result is a whole number of units, with no fractions.
2. Time Bucketing
Grouping data into time buckets:
Hourly Bucket = Floor(Minutes Since Start ÷ 60)
Weekly Bucket = Floor(Days Since Start ÷ 7)
3. Price Level Discretization
Rounding prices to tick sizes or round numbers:
Tick Level = Floor(Price ÷ Tick Size)
4. Ratio Thresholds
Counting how many times one value "fits into" another:
Multiplier = Floor(Target ÷ Baseline)
Edge Cases
| Situation | Result | Notes |
|---|---|---|
| Division by zero | empty | The result is undefined, so no value is invented |
| Both values zero | empty | Same rule |
| Negative numerator | Rounds down (toward −∞) | −7 ÷ 3 = −3 |
| Negative denominator | Standard floor behavior | 7 ÷ −3 = −3 |
| Very large values | Valid whole number | May lose precision for extremely large numbers |
| Decimal inputs | Treated as real numbers | Decimals are not stored exactly, so a result can be one lower than expected (1 ÷ 0.1 gives 9) |
Missing Data
- If either input is empty (null) on a bar, for example a data gap or a closed-market day, the quotient is empty on that bar. No substitute value is used.
- Division by zero is different from missing data: both inputs exist, but the result is undefined. The output is also empty on that bar.
Key Takeaways
| Property | Value |
|---|---|
| Output Type | Whole number, or empty when it cannot be calculated |
| Rounding Direction | Always toward −∞ |
| Zero Division | Returns empty (undefined result) |
| Missing Inputs | Return empty on the same bar |
| Best for | Lot sizing, bucketing, discretization |
Further Reading
- Floor and Ceiling Functions — Mathematical foundation