Floor Division
systemic:core-fdivMathfunction1 crInputs
| Name | Type | Description |
|---|---|---|
| First Value | floatarray | The dividend—the value to be divided. |
| Second Value | floatarray | The divisor—the value to divide by. |
Outputs
| Name | Type | Description |
|---|---|---|
| Quotient | floatarray | The integer result of floor division. |
Floor Division divides two values and rounds down to the nearest integer—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. This means −7 ÷ 3 = −3 (not −2).
Worked Example
Calculating how many complete lots can be purchased:
| Available Capital | Lot Size | Floor Division | Interpretation |
|---|---|---|---|
| 10,000 | 3,000 | 3 | Can buy 3 complete lots |
| 10,000 | 4,000 | 2 | Can buy 2 complete lots |
| 10,000 | 7,000 | 1 | Can buy 1 complete lot |
| 5,500 | 2,000 | 2 | Can buy 2 complete lots (remainder 1,500) |
Practical Applications
1. Lot Sizing and Position Calculation
When determining how many shares or contracts to trade:
Position Size = Floor(Capital Available ÷ Price per Unit)
This ensures you never attempt to buy fractional units that aren't tradeable.
2. Time Bucketing
Grouping data into discrete time periods:
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 | null | The math is undefined — no value is invented |
| Both values zero | null | Same undefined-math rule |
| Negative numerator | Rounds down (toward −∞) | −7 ÷ 3 = −3 |
| Negative denominator | Standard floor behavior | 7 ÷ −3 = −3 |
| Very large values | Valid integer result | May lose precision for extremely large numbers |
| Decimal inputs | Treated as real numbers | Floor applies after division |
Missing Data
- If either input is missing (null) at a position — a data gap or a closed-market day — the quotient is null at that same position. The math is never faked with substitute values.
- Division by zero is different from missing data: both inputs exist, but the result is mathematically undefined — the output is also null at that position.
- In live execution the module returns exactly one datapoint: the newest one, which is null when it cannot be determined.
Key Takeaways
| Property | Value |
|---|---|
| Output Type | Integer (whole number), or null when undeterminable |
| Rounding Direction | Always toward −∞ |
| Zero Division | Returns null (undefined math) |
| Missing Inputs | Return null at the same position |
| Best for | Lot sizing, bucketing, discretization |
Further Reading
- Floor and Ceiling Functions — Mathematical foundation
- Python Floor Division — Implementation reference