DAS Script Units, Precision and Rounding
Make Round and unit conversions explicit, with hand-checkable examples.
A number needs a unit
Prerequisite: expressions and conditions. Distinguish dollars per share, cents per share, shares, dollars and percentages. Division can be mathematically correct while producing the wrong unit. Write units beside configuration values. This lesson calculates hypothetical values and never writes a Montage field.
Round is not a generic Floor
The June 2025 guide documents precision 1–6 for decimal digits; 100 rounds down to even lots, and 101 rounds to the closest even lots. Treat the lot modes as lot modes, not arbitrary integer rounding. Do not infer a precision=0 contract from another language. Confirm the instrument’s lot convention in your environment before translating results into quantities.
A worksheet you can verify by hand
$feModelBudget = 42;
$feDistanceCents = 35;
$feDistanceDollars = $feDistanceCents / 100;
$feRawQuantity = $feModelBudget / $feDistanceDollars;
$feDisplayDistance = Round($feDistanceDollars, 2);
$feLotQuantity = Round($feRawQuantity, 100);
$feModelExposure = $feLotQuantity * $feDistanceDollars;
MsgBox($feRawQuantity, $feLotQuantity, $feModelExposure);
Explain every transformation
35 cents becomes 0.35 dollars per share. 42/0.35 gives 120 shares before lot rounding. Under a verified 100-share lot convention, mode 100 gives 100 shares and the model exposure is 35 dollars. Those are model outputs, not maximum-loss guarantees. The displayed distance is separate from the calculation input: rounding for presentation must not silently change a denominator.
Boundary cases and order of constraints
Validate the denominator before division. Apply a quantity cap before final lot normalization and recompute the resulting notional or exposure afterward. A cap of 150 combined with 100-share lots should not be rounded to 200. Test values immediately below and above a lot boundary, fractional values and values below one lot. Zero after normalization means no valid model quantity under that policy; it does not mean substitute a minimum automatically.
Exercise and worked answer
Use a 63-dollar budget and 0.35-dollar distance, a 150-share cap and verified 100-share lots. Answer: raw 180; capped 150; rounded down 100; recomputed model exposure 35. Changing the distance to zero must stop before division. Changing it to 0.004 must not be rounded to zero as part of a display operation.