Package 

Class MeasurementWheelKt

    • Method Detail

      • measurementRoundHalfAway

         final static Double measurementRoundHalfAway(Double x)

        Pinned half-away-from-zero rounding: sign(x) * floor(abs(x) + 0.5). The ONE algorithm shared across iOS/Android/JS — it deliberately does NOT use Kotlin's Math.round/roundToLong (which is half-up, differs on negatives) so negatives match Swift/JS. sign(0) == 0.

      • measurementSnap

         final static Double measurementSnap(Double value, MeasurementUnit unit)

        Snap a value to unit.step/unit.decimals, THEN clamp to [unit.min, unit.max]. Clamp is the FINAL op and uses min(max(d,lo),hi) (never Kotlin coerceIn, which throws on lo > hi) so non-step-aligned custom ranges still land on the boundary.

      • measurementScalar

         final static Object measurementScalar(Double v)

        Persist as a whole integer (Long, mirroring the legacy drum's if (v == v.toLong().toDouble()) v.toLong() else v at ContentBlockRenderer.kt:5674) when whole, Double otherwise. Keeps answer_equals numeric routing consistent.

      • parseMeasurementConfig

         final static MeasurementConfig parseMeasurementConfig(ContentBlock block)

        Parse + validate the measurement config. Returns null (→ legacy drum fallback) when measurement_type is unset, units is empty/unresolvable, or ANY unit is degenerate (factor==0, step<=0, min>=max). A unit_default that matches no unit is NOT a fallback trigger — it resolves to units[0] and stays in measurement mode.