class Decimal {

    public static byte[] fromLogical(Schema schema, BigDecimal value) {
        if (value.scale() != scale(schema))
            throw new DataException("BigDecimal has mismatching scale value for given Decimal schema");
        return value.unscaledValue().toByteArray();
    }

}