Download calculation/limits.md from swedishembedded/knowledge: direct link, hf CLI and curl.
- Browser
- Download file 4.07 kB
-
https://huggingface.co/swedishembedded/knowledge/resolve/main/calculation/limits.md
- Command line
-
hf download hf://swedishembedded/knowledge/calculation/limits.md
-
curl -L -o limits.md https://huggingface.co/swedishembedded/knowledge/resolve/main/calculation/limits.md
title: Limits - thresholds, caps, windows, whole months
tiers: rule 1, procedure 2, example 3, mistakes 2
Limits: thresholds, caps, windows, whole months
For comparisons with a limit, capped amounts, "in the last N days" counts and whole months.
Rule
The task's own files and stated rules always win over this page; use this page only for what the task leaves open.
The wording of a limit decides whether the boundary value counts.
Wording Test Is exactly N included? at most N, up to N, no more than N, within N value <= N yes at least N, N or more value >= N yes more than N, exceeds N, over N, above N value > N no less than N, under N, below N value < N no A limit is a bound, not a target. Staying under a maximum is fine.
A rate with a cap ("x per day, at most y") is the smaller of the computed amount and the cap. The cap is the answer only when the computed amount reaches it.
"Per commenced" unit: any started week or month counts as a whole one. Count = days / unit length, rounded up.
A threshold stated in weeks, where the task tests it in days, is weeks x 7 days of that threshold, not the number of commenced weeks.
Two limits on one thing ("within N days of discovery and in any event within M months of delivery"): the earlier date governs.
A look-back window "in the last N days" covers dates from today - N up to today, where today is the task's date, unless the task words the window differently.
Whole calendar months from the first of one month to the end of another: (end year - start year) x 12 + (end month - start month) + 1.
Procedure
Comparing with a limit:
- Copy the limit's wording from the task. Find it in the table above.
- Put both values in the same unit.
A capped amount:
- Count the units (round up for "commenced").
- Computed = base x rate x units. Cap = base x cap rate (or the fixed cap).
- Result = the smaller. Round half up at the end.
A look-back count:
- Window start = today - N days.
- Keep the events dated from window start to today.
- Count them in the script; compare with the threshold by its wording.
Months of a span after a period end:
- Total months of the span (rule 8). Monthly amount = amount / total months.
- Months after = months of the span later than the period's own month. A span ending on or before the period end has none.
- Amount after = monthly amount x months after.
Worked example
Illustration only, with invented data. Your task's data differs: take no fact, count or expected result from this example.
Capped penalty. Order value 52000.00. Penalty 0.5 percent per commenced week, at most 6 percent. Delay 17 days. Weeks = 17 / 7 rounded up = 3. Computed = 52000.00 x 0.005 x 3 = 780.00. Cap = 3120.00. Result 780.00.
Threshold in weeks. "May end the contract if the delay exceeds 5 weeks": needs more than 35 days. 17 days: no. Exactly 35 days: still no. 36 days: yes.
Boundary. "A full refund within 14 days of delivery." Day 14: yes. Day 15: no.
Look-back. "At least 4 complaints in the last 60 days." Today is 2031-09-20, so the window starts 2031-07-22. Complaint dates: 07-10, 07-30, 08-15, 09-01, 09-18. The first is outside. Four remain: the rule applies. With "more than 4" it would not.
Months after a period end. A cost of 3600.00 covers 2031-03-01 to 2031-08-31: 6 months, 600.00 each. Period end 2031-04-30. Months after: May to August = 4. Amount after: 2400.00.
Common mistakes
- Reading "more than N" as "N or more", or "within N" as "less than N".
- Reporting the cap as the amount although the computed amount is below it.
- Testing a weeks threshold with the commenced-week count instead of days against weeks x 7.
- Taking the later of two limits where the earlier governs.