IETS3 / iets3.opensource

Open Source Parts of IETS3
Apache License 2.0
44 stars 22 forks source link

physunits: improve implicit conversions #1100

Closed alexanderpann closed 2 weeks ago

alexanderpann commented 3 weeks ago

I also have to fix the type calculation for div expressions since they contained unnecessary trailing zeros which leads to ugly number ranges with those implicit conversions. The changes for the type calculation were also done for the convertTo expression.

Implementation details: The reason why we need to widen the precision in the tagged expression is that the interpreter needs to work with BigDecimal and not BigInteger in our calculations and with this change we enforce floating point calculation. The previous real type was not necessary, changing the precision is enough. I also try to use the precision and range from the original expression if possible. The conversions itself can overwrite this, so we do this only for implicit generated conversions rule of prefixes.

Examples:

Screenshot 2024-10-31 at 08 27 26 Screenshot 2024-10-31 at 08 19 16