public double applyMinMaxRescaleCast(double prediction) throws Exception {
    if (m_optype != Optype.CONTINUOUS) {
      throw new Exception("[TargetMetaInfo] target must be continuous!");
    }

    if (!Utils.isMissingValue(m_min) && prediction < m_min) {
      prediction = m_min;
    }
    if (!Utils.isMissingValue(m_max) && prediction > m_max) {
      prediction = m_max;
    }

    prediction *= m_rescaleFactor;
    prediction += m_rescaleConstant;

    if (m_castInteger.length() > 0) {
      if (m_castInteger.equals("round")) {
        prediction = Math.round(prediction);
      } else if (m_castInteger.equals("ceiling")) {
        prediction = Math.ceil(prediction);
      } else if (m_castInteger.equals("floor")) {
        prediction = Math.floor(prediction);
      } else {
        throw new Exception("[TargetMetaInfo] unknown castInteger value "
                            + m_castInteger);
      }
    }
    
    return prediction;
  }