From c2fd0ac9e63bf6e28ee0f55a14a6257ff8e872b7 Mon Sep 17 00:00:00 2001 From: Klaus Birken Date: Wed, 14 Jan 2026 16:56:29 +0100 Subject: [PATCH] Fix infinite precision bug for prefixed units (#1593). Details: - add failing tests showing the problem with infinite precisions - compute proper precision for number types with prefixed unit - update CHANGELOG --- CHANGELOG.md | 4 +- .../models/behavior.mps | 119 +++++++++ ...ore.expr.typetags.physunits.typesystem.mps | 239 ++++++++++++++++-- .../models/test.ts.expr.os.phyunits@tests.mps | 135 +++++++++- 4 files changed, 476 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b77a52d45..80e0451a9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,9 @@ The project does _not_ follow Semantic Versioning and the changes are documented ### Fixed -- Physical units: The units `Joule`, `Coulomb` and `Watt` can now have also prefixes with negative metric scaling, e.g., `mW` (Milliwatt). Additionally, some typos have been corrected in the physical units documentation. +- Physical units: + - The units `Joule`, `Coulomb` and `Watt` can now have also prefixes with negative metric scaling, e.g., `mW` (Milliwatt). Additionally, some typos have been corrected in the physical units documentation. + - The precision of number types with prefixed units (e.g. `mW` or `km`) was always set to `infinite` by the typesystem. Now, the precision is as precise as possible. ## December 2025 diff --git a/code/languages/org.iets3.opensource/languages/org.iets3.core.expr.simpleTypes/models/behavior.mps b/code/languages/org.iets3.opensource/languages/org.iets3.core.expr.simpleTypes/models/behavior.mps index 24bbf6493c..16d3ba76c7 100644 --- a/code/languages/org.iets3.opensource/languages/org.iets3.core.expr.simpleTypes/models/behavior.mps +++ b/code/languages/org.iets3.opensource/languages/org.iets3.core.expr.simpleTypes/models/behavior.mps @@ -10,6 +10,7 @@ + @@ -221,6 +222,18 @@ + + + + + + + + + + + + @@ -287,6 +300,7 @@ + @@ -2613,6 +2627,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6136,6 +6182,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/languages/org.iets3.opensource/languages/org.iets3.core.expr.typetags.physunits/models/org.iets3.core.expr.typetags.physunits.typesystem.mps b/code/languages/org.iets3.opensource/languages/org.iets3.core.expr.typetags.physunits/models/org.iets3.core.expr.typetags.physunits.typesystem.mps index 96610efbe5..7c9ba5b53d 100644 --- a/code/languages/org.iets3.opensource/languages/org.iets3.core.expr.typetags.physunits/models/org.iets3.core.expr.typetags.physunits.typesystem.mps +++ b/code/languages/org.iets3.opensource/languages/org.iets3.core.expr.typetags.physunits/models/org.iets3.core.expr.typetags.physunits.typesystem.mps @@ -12526,13 +12526,31 @@ - - - - + + + + + + + + + + + - - + + + + + + + + + + + + + @@ -12554,24 +12572,209 @@ - - - - - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/languages/org.iets3.opensource/tests/test.ts.expr.os/models/test.ts.expr.os.phyunits@tests.mps b/code/languages/org.iets3.opensource/tests/test.ts.expr.os/models/test.ts.expr.os.phyunits@tests.mps index 252525534b..f975471d97 100644 --- a/code/languages/org.iets3.opensource/tests/test.ts.expr.os/models/test.ts.expr.os.phyunits@tests.mps +++ b/code/languages/org.iets3.opensource/tests/test.ts.expr.os/models/test.ts.expr.os.phyunits@tests.mps @@ -5521,6 +5521,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5732,7 +5863,7 @@ - + @@ -9439,7 +9570,7 @@ - +