|
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
4.07 kB
| # SPDX-License-Identifier: CC-BY-4.0 | |
| # Copyright (c) 2026 Martin Schröder <info@swedishembedded.com> | |
| 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. | |
| <!-- tier: 1 --> | |
| ## Rule | |
| **The task's own files and stated rules always win over this page; use this page only for what | |
| the task leaves open.** | |
| 1. **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 | | |
| 2. **A limit is a bound, not a target.** Staying under a maximum is fine. | |
| 3. **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. | |
| 4. **"Per commenced" unit:** any started week or month counts as a whole one. Count = days / | |
| unit length, rounded up. | |
| 5. **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. | |
| 6. **Two limits on one thing** ("within N days of discovery and in any event within M months of | |
| delivery"): the earlier date governs. | |
| 7. **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. | |
| 8. **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. | |
| <!-- tier: 2 --> | |
| ## Procedure | |
| Comparing with a limit: | |
| 1. Copy the limit's wording from the task. Find it in the table above. | |
| 2. Put both values in the same unit. | |
| A capped amount: | |
| 1. Count the units (round up for "commenced"). | |
| 2. Computed = base x rate x units. Cap = base x cap rate (or the fixed cap). | |
| 3. Result = the smaller. Round half up at the end. | |
| A look-back count: | |
| 1. Window start = today - N days. | |
| 2. Keep the events dated from window start to today. | |
| 3. Count them in the script; compare with the threshold by its wording. | |
| Months of a span after a period end: | |
| 1. Total months of the span (rule 8). Monthly amount = amount / total months. | |
| 2. Months after = months of the span later than the period's own month. A span ending on or | |
| before the period end has none. | |
| 3. Amount after = monthly amount x months after. | |
| <!-- tier: 3 --> | |
| ## 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. | |
| <!-- tier: 2 --> | |
| ## 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. | |