Hi all,
We were discussing numeric rounding in openEHR and realized that, as far as we can tell, the specifications do not define a normative rounding mode.
One example is DV_QUANTITY.precision, where a value may be rounded to a certain number of decimal places. However, this could also matter in other places, for example in archetype rules or other validation/calculation contexts. Without a specified rounding mode, different implementations could produce different results for the same input.
For example, when rounding -2.5 to an integer:
round half toward positive infinity: -2 // e.g. Java Math.round()
HALF_UP / half away from zero: -3
HALF_EVEN / banker's rounding: -2
In Archie, we currently use round half toward positive infinity in some places, simply because we rely on Javaâs Math.round(). However, weâre not sure whether that is the most appropriate behavior to standardize, or whether something like HALF_EVEN or HALF_UP would be preferable.
Weâre also wondering whether there are existing recommendations or standards in the medical or scientific domain (or IEEE/ISO/HL7/UCUM) that openEHR should align with.
Our questions are:
-
Is the absence of a specified rounding mode intentional?
-
Would it make sense for openEHR to define a normative rounding mode?
-
If so, which rounding mode would be most appropriate?
-
Are there existing standards or conventions that openEHR should follow?
-
If this were to be specified, where would be the most appropriate place? We were thinking of somewhere central in the BASE specification (e.g. on the
base_typespage), so that the same rounding semantics apply consistently throughout openEHR.
Weâre curious to hear your thoughts.