Utility method used to round a double to the given precision.

@param value value to truncate
@param precision Number of decimals to round to.
@return double value
430339
public static final double round(double value, double precision)
   {
      precision = Math.pow(10, precision);
      return Math.round(value * precision) / precision;
   }
1078346
public double setFixedValue(double value) throws IOException, SaneException {
    Preconditions.checkArgument(
        value >= -32768 && value <= 32767.9999, "value " + value + " is out of range");
    SaneWord wordValue = SaneWord.forFixedPrecision(value);
    ControlOptionResult result = writeOption(wordValue);
    Preconditions.checkState(
        result.getType() == OptionValueType.FIXED,
        "setFixedValue is not appropriate for option of type " + result.getType());

    return SaneWord.fromBytes(result.getValue()).fixedPrecisionValue();
  }
427788
public static final Integer getInteger(Number value)
   {
      Integer result = null;
      if (value != null)
      {
         if (value instanceof Integer)
         {
            result = (Integer) value;
         }
         else
         {
            result = Integer.valueOf((int) Math.round(value.doubleValue()));
         }
      }
      return (result);
   }
841710
public DoubleConstant addDouble(double value)
  {
    DoubleConstant entry = getDoubleByValue(value);

    if (entry != null)
      return entry;

    entry = new DoubleConstant(this, _entries.size(), value);

    addConstant(entry);
    addConstant(null);

    return entry;
  }
300312
function (value, offset) {
                if (undefined === offset) {
                    offset = this.offset;
                }
                this.writeInt32(Math.round(value * 65536), offset);

                return this;
            }
634688
public static Double asDouble(Object value) {
    double doubleValue;
    switch (value.getClass().getCanonicalName()) {
      case "java.math.BigDecimal":
        doubleValue = ((BigDecimal) value).doubleValue();
        break;
      case "java.lang.Integer":
        doubleValue = ((Integer) value).doubleValue();
        break;
      default:
        doubleValue = (Double) value;
        break;
    }
    return doubleValue;
  }
78597
private static double scale(MetricDto metric, double value) {
    if (metric.getDecimalScale() == null) {
      return value;
    }
    BigDecimal bd = BigDecimal.valueOf(value);
    return bd.setScale(metric.getDecimalScale(), RoundingMode.HALF_UP).doubleValue();
  }
1345213
public static Double isDouble(String value) {
		Validate.notNull(value);
		Validate.notEmpty(value);
		Double doubleValue = null;
		try{
			doubleValue = Double.parseDouble(value);
		} catch(NumberFormatException e){
			throw new TypeException("Double");
		}
		return doubleValue;
	}
717902
public static NumberData round(SoyValue value, int numDigitsAfterPoint) {
    // NOTE: for more accurate rounding, this should really be using BigDecimal which can do correct
    // decimal arithmetic.  However, for compatibility with js, that probably isn't an option.
    if (numDigitsAfterPoint == 0) {
      return IntegerData.forValue(round(value));
    } else if (numDigitsAfterPoint > 0) {
      double valueDouble = value.numberValue();
      double shift = Math.pow(10, numDigitsAfterPoint);
      return FloatData.forValue(Math.round(valueDouble * shift) / shift);
    } else {
      double valueDouble = value.numberValue();
      double shift = Math.pow(10, -numDigitsAfterPoint);
      return IntegerData.forValue((int) (Math.round(valueDouble / shift) * shift));
    }
  }
858646
public static float round(Float number, int precision) {
        return (float)(Math.floor(number.doubleValue()*Math.pow(10,precision)+0.5)/Math.pow(10,precision));
    }
334599
static int round(int value, int precision, int significantDigits) {
		if (precision > 0) {
			value = (value + precision / 2) / precision * precision;
		}
		if (significantDigits > 0) {
			int forRounding = value;
			int precisionMax = (int) Math.pow(10, significantDigits);
			int multiplier = 1;
			while (value > precisionMax) {
				forRounding = value;
				multiplier *= 10;
				value /= 10;
			}
			if (forRounding % 10 >= 5) {
				value++;
			}
			value *= multiplier;
		}
		return value;
	}
608591
@SuppressWarnings("unchecked")
    private T roundOffValueToStep(T value) {
        double d = Math.round(value.doubleValue() / absoluteStepValuePrim) * absoluteStepValuePrim;
        return (T) numberType.toNumber(Math.max(absoluteMinValuePrim, Math.min(absoluteMaxValuePrim, d)));
    }
1109316
public static void validateTotalDigits(int totalDigits, double value){
        String doubleValue = String.valueOf(value);

        int numberOfDigits;

        if (value != ((int) value)){
            numberOfDigits = doubleValue.length() - 1;
        } else {
            numberOfDigits = doubleValue.length();
        }

        if (numberOfDigits != totalDigits){
            throw new RestrictionViolationException("Violation of fractionDigits restriction, value should have a exactly " + totalDigits + " decimal places.");
        }
    }
261747
public static long round(SoyValue value) {
    if (value instanceof IntegerData) {
      return value.longValue();
    } else {
      return Math.round(value.numberValue());
    }
  }
1284150
private function roundValue( $value, $precision )
	{
		if ( $precision == INF ) return $value;
		return round( $value, \XBRL_Instance::inferDecimals( $value, $precision ) );
	}
1209028
public double precision(int outputNum) {
        assertIndex(outputNum);
        //double precision = tp / (double) (tp + fp);
        return countTruePositive[outputNum] / (double) (countTruePositive[outputNum] + countFalsePositive[outputNum]);
    }
824184
function toFixed ( value, decimals ) {
		var scale = Math.pow(10, decimals);
		return ( Math.round(value * scale) / scale).toFixed( decimals );
	}