UnitsNet icon indicating copy to clipboard operation
UnitsNet copied to clipboard

Brackets missing when there are multiple denominators in units string

Open glyn-horsham opened this issue 2 years ago • 1 comments

According to the BODMAS mathematical convention, division comes before multiplication, therefore, the unit definitions where there are multiple denominators should be in brackets to avoid confusion between, say, W/m^2·C and (W/m^2)·C

For example, for heat transfer coefficients: "Abbreviations": [ "kcal/h·m²·°C", "kcal/m²·h·°C", "kcal/hr·m²·°C", "kcal/m²·hr·°C" ] should be "Abbreviations": [ "kcal/(h·m²·°C)", "kcal/(m²·h·°C)", "kcal/(hr·m²·°C)", "kcal/(m²·hr·°C)" ]

This applies to multiple units in the code, from glancing though, I have found HeatTransferComponents and VolumetricHeatCapacity, but there maybe others.

glyn-horsham avatar Jan 03 '24 10:01 glyn-horsham

Thank you for reporting, would you be interested in attempting a pull request?

We can't remove abbreviations, it would be a breaking change on parsing and should be done as part of #1200 , but we can safely add the new variations and we can also change which abbreviation is first in the list of abbreviations, which is used by ToString() by default.

angularsen avatar Jan 05 '24 08:01 angularsen

Fixed by #1405

angularsen avatar Jul 08 '24 13:07 angularsen