diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-24 23:10:22 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-24 23:10:22 +0300 |
| commit | 50bff2ffa7a09f3ae35b10219b49d5cf38457066 (patch) | |
| tree | 997173667c42b78d902ce8f715d52af72b238e6a /docs/comparisons.md | |
| parent | dc89fa2bbcdea7c8847828f64be5e46ddded33fb (diff) | |
docs: de-LLM all .md files - remove corporate language, over-explanation, and LLM patterns
Diffstat (limited to 'docs/comparisons.md')
| -rw-r--r-- | docs/comparisons.md | 110 |
1 files changed, 9 insertions, 101 deletions
diff --git a/docs/comparisons.md b/docs/comparisons.md index 3c990a7..0f82ec2 100644 --- a/docs/comparisons.md +++ b/docs/comparisons.md @@ -1,9 +1,6 @@ # Comparison RPN Operators -`gt` provides six comparison operators, each with both a named and a symbolic -alias. All operators are metric-aware — they convert values to base units -before comparing. Results are boolean (`true` / `false`) and coerce -seamlessly into arithmetic (true → 1, false → 0). +gt provides six comparison operators, each with both a named and a symbolic alias. All operators are metric-aware — they convert values to base units before comparing. Results are boolean (`true` / `false`) and coerce into arithmetic (true → 1, false → 0). ## Operators @@ -16,8 +13,7 @@ seamlessly into arithmetic (true → 1, false → 0). | `eq` | `==` | `a b eq` | `a == b`| Equal | | `neq` | `!=` | `a b neq` | `a != b`| Not equal | -All operators pop two values (`a` first, then `b`) from the stack, compare -them, and push the boolean result. +All operators pop two values (`a` first, then `b`) from the stack, compare them, and push the boolean result. ## Truth Table @@ -44,13 +40,6 @@ true | 5 | 3 | false | | 5 | 5 | false | -``` -$ gt '3 5 lt' -true -$ gt '3 5 <' -true -``` - ### `gte` / `>=` | a | b | Result | @@ -59,13 +48,6 @@ true | 5 | 5 | true | | 3 | 5 | false | -``` -$ gt '5 5 gte' -true -$ gt '5 3 >=' -true -``` - ### `lte` / `<=` | a | b | Result | @@ -74,13 +56,6 @@ true | 5 | 5 | true | | 5 | 3 | false | -``` -$ gt '5 5 lte' -true -$ gt '3 5 <=' -true -``` - ### `eq` / `==` | a | b | Result | @@ -88,13 +63,6 @@ true | 5 | 5 | true | | 5 | 3 | false | -``` -$ gt '5 5 eq' -true -$ gt '5 5 ==' -true -``` - ### `neq` / `!=` | a | b | Result | @@ -102,17 +70,9 @@ true | 5 | 3 | true | | 5 | 5 | false | -``` -$ gt '5 3 neq' -true -$ gt '5 3 !=' -true -``` - ## Metric-Aware Comparison -Comparison operators convert operands to base units before comparing, so -different units within the same category can be compared directly. +Comparison operators convert operands to base units before comparing, so different units within the same category can be compared directly. ### Same category, different units @@ -136,8 +96,7 @@ $ gt '1GB 1024MB eq' false ``` -`1GB` equals exactly `1000MB` (decimal SI), so `gt` is false and `gte` is -true. `1024MB` is not equal to `1GB`. +`1GB` equals exactly `1000MB` (decimal SI), so `gt` is false and `gte` is true. `1024MB` is not equal to `1GB`. ### Network throughput @@ -157,19 +116,11 @@ $ gt '5m 3kg gt' Error: incompatible metric categories ``` -Examples of incompatible pairs: - -- Distance vs. weight: `1km 5kg >` -- Time vs. bandwidth: `1hr 100Mbps <` -- Mass vs. distance: `10lb 5mi >=` - Unitless numbers are always compatible with any metric value. ## Boolean Coercion in Arithmetic -Boolean results are represented as floating-point numbers: `true` → 1, -`false` → 0. This allows comparison results to flow directly into arithmetic -without explicit conversion. +Boolean results coerce to numbers: `true` → 1, `false` → 0. This lets comparison results flow directly into arithmetic. ### Conditional addition @@ -192,17 +143,10 @@ $ gt '3 5 gt 1 +' ``` $ gt '5 3 gt 10 *' 10 -``` - -`5 > 3` is true (1), so `1 * 10 = 10`. - -``` $ gt '3 5 gt 10 *' 0 ``` -`3 > 5` is false (0), so `0 * 10 = 0`. - ### Chained comparisons ``` @@ -217,23 +161,14 @@ $ gt '9 3 gt 4 5 lt +' ``` $ gt '5 3 gt 0 -' 1 -``` - -`5 > 3` (true/1) - 0 = 1. - -``` $ gt '5 5 eq 1 -' 0 ``` -`5 == 5` (true/1) - 1 = 0. - -## Practical Use Cases +## Examples ### Threshold checks -Test whether a value exceeds a threshold: - ``` $ gt '85 80 gt' true @@ -241,13 +176,6 @@ true CPU at 85%, threshold at 80% — alert. -``` -$ gt '50 10 gte' -true -``` - -Disk free at 50%, minimum at 10% — OK. - ### Range validation Check that a value falls within acceptable bounds: @@ -257,24 +185,19 @@ $ gt '72 68 gte 100 lte +' 2 ``` -Temperature 72°F: `72 >= 68` (true/1) + `72 <= 100` (true/1) = 2 (both -checks pass). +Temperature 72°F: `72 >= 68` (true/1) + `72 <= 100` (true/1) = 2 (both checks pass). ``` $ gt '105 68 gte 100 lte +' 1 ``` -Temperature 105°F: `105 >= 68` (true/1) + `105 <= 100` (false/0) = 1 -(outside range). +Temperature 105°F: `105 >= 68` (true/1) + `105 <= 100` (false/0) = 1 (outside range). -When the sum is 2, the value is within range. Any other result means at -least one check failed. +When the sum is 2, the value is within range. Any other result means at least one check failed. ### Metric validation -Validate that a metric measurement meets requirements: - ``` $ gt '100Mbps 50Mbps gt' true @@ -282,13 +205,6 @@ true Download speed 100Mbps exceeds minimum 50Mbps — pass. -``` -$ gt '2hr 1hr gte' -true -``` - -Battery life 2hr meets minimum 1hr requirement — pass. - ### Counting conditions Sum boolean results to count how many conditions are met: @@ -350,11 +266,3 @@ Error: stack is empty $ gt '5 gt' Error: stack has insufficient operands ``` - -## Summary - -Comparison operators provide boolean results that integrate naturally into -RPN arithmetic. The metric-aware design lets you compare values across units -automatically, while the symbolic aliases (`>`, `<`, `>=`, `<=`, `==`, -`!=`) offer familiar notation alongside the named operators (`gt`, `lt`, -`gte`, `lte`, `eq`, `neq`). |
