Systemicalpha

Floor Division

systemic:core-fdivMathfunction1 cr

Inputs

NameTypeDescription
First ValuefloatarrayThe dividend—the value to be divided.
Second ValuefloatarrayThe divisor—the value to divide by.

Outputs

NameTypeDescription
QuotientfloatarrayThe integer result of floor division.

Floor Division divides two values and rounds down to the nearest integer—always toward negative infinity.


The Formula

Qi=⌊AiBi⌋Q_i = \left\lfloor \frac{A_i}{B_i} \right\rfloor

Where:

  • AA = First Value (numerator)
  • BB = Second Value (denominator)
  • ⌊⋅⌋\lfloor \cdot \rfloor = Floor function (round down toward −∞)

Floor vs. Regular Division

ExpressionRegular DivisionFloor Division
7 ÷ 32.333...2
10 ÷ 42.52
−7 ÷ 3−2.333...−3
−10 ÷ −42.52

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 CapitalLot SizeFloor DivisionInterpretation
10,0003,0003Can buy 3 complete lots
10,0004,0002Can buy 2 complete lots
10,0007,0001Can buy 1 complete lot
5,5002,0002Can 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

SituationResultNotes
Division by zeronullThe math is undefined — no value is invented
Both values zeronullSame undefined-math rule
Negative numeratorRounds down (toward −∞)−7 ÷ 3 = −3
Negative denominatorStandard floor behavior7 ÷ −3 = −3
Very large valuesValid integer resultMay lose precision for extremely large numbers
Decimal inputsTreated as real numbersFloor 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

PropertyValue
Output TypeInteger (whole number), or null when undeterminable
Rounding DirectionAlways toward −∞
Zero DivisionReturns null (undefined math)
Missing InputsReturn null at the same position
Best forLot sizing, bucketing, discretization

Further Reading

© 2026 WanoLabs. All rights reservedAlpha build v0.1.5