:param value:  THE VALUE TO ROUND
    :param decimal: NUMBER OF DECIMAL PLACES TO ROUND (NEGATIVE IS LEFT-OF-DECIMAL)
    :param digits: ROUND TO SIGNIFICANT NUMBER OF digits
    :param places: SAME AS digits
    :return:
167290
def round(value, decimal=None, digits=None, places=None):
    
    value = float(value)
    if value == 0.0:
        return "0"

    digits = coalesce(digits, places)
    if digits != None:
        left_of_decimal = int(math.ceil(math.log10(abs(value))))
        decimal = digits - left_of_decimal

    right_of_decimal = max(decimal, 0)
    format = "{:." + text_type(right_of_decimal) + "f}"
    return format.format(_round(value, decimal))
669939
def real_value(value, digit):
    
    return str(float(value) / math.pow(10, float(digit)))
1043403
private double round(double value, int precision) {
    return BigDecimal.valueOf(value)
        .setScale(precision, RoundingMode.HALF_UP)
        .doubleValue();
  }
894297
def round(digits = nil)
      rounded_value = digits ? value.round(digits) : value.round
      self.class.new(rounded_value, unit)
    end
178082
def to_decimal(value, ctx):
    
    if isinstance(value, bool):
        return Decimal(1) if value else Decimal(0)
    elif isinstance(value, int):
        return Decimal(value)
    elif isinstance(value, Decimal):
        return value
    elif isinstance(value, str):
        try:
            return Decimal(value)
        except Exception:
            pass

    raise EvaluationError("Can't convert '%s' to a decimal" % str(value))
599037
def inasafe_place_value_coefficient(number, feature, parent):
    
    _ = feature, parent  # NOQA

    if number >= 0:
        rounded_number = round_affected_number(
            number,
            use_rounding=True,
            use_population_rounding=True
        )
        min_number = 1000
        value, unit = denomination(rounded_number, min_number)
        if number < min_number:
            rounded_number = int(round(value, 1))
        else:
            rounded_number = round(value, 1)
        return str(rounded_number)
    else:
        return None
365589
def adapt_decimalfield_value(self, value, max_digits, decimal_places):
        
        if value is None:
            return None
        if isinstance(value, decimal.Decimal):
            context = decimal.getcontext().copy()
            context.prec = max_digits
            #context.rounding = ROUND_FLOOR
            return "%.*f" % (decimal_places + 1, value.quantize(decimal.Decimal(".1") ** decimal_places, context=context))
        else:
            return "%.*f" % (decimal_places + 1, value)
509536
def round_two_non_zero_dp(decimal):
    
    log10 = decimal.log10().to_integral_exact(rounding=ROUND_FLOOR) \
        if decimal else 0
    div = Decimal(10) ** (Decimal(1) - log10) if log10 < 0 else Decimal(100)
    return (decimal * div).to_integral_exact(rounding=ROUND_HALF_UP) / div
1096338
def isdigit(cls, value):
        
        if str(value).replace('.','').replace('-','').isdigit():
            return True
        return False
690007
def roundClosestValid(val, res, decimals=None):
        
        if decimals is None and "." in str(res):
            decimals = len(str(res).split('.')[1])

        return round(round(val / res) * res, decimals)
1231773
function(value, precision, base){
    var sizes =         ['Y','Z','E','P','T','G','M','k',''],
        fractionSizes = ['y','z','a','f','p','n','µ','m',''],
        total = sizes.length;

    base = base || 1000;
    precision = Math.pow(10, precision || 2);

    if (value === 0) return 0;

    if (value > 1) {
      while (total-- && (value >= base)) value /= base;
    }
    else {
      sizes = fractionSizes;
      total = sizes.length;
      while (total-- && (value < 1)) value *= base;
    }

    return (Math.round(value * precision) / precision) + sizes[total];
  }
1317976
def trim_decimals(s, precision=-3):
        
        encoded = s.encode('ascii', 'ignore')
        str_val = ""
        if six.PY3:
            str_val = str(encoded, encoding='ascii', errors='ignore')[:precision]
        else:
            # If precision is 0, this must be handled seperately
            if precision == 0:
                str_val = str(encoded)
            else:
                str_val = str(encoded)[:precision]
        if len(str_val) > 0:
            return float(str_val)
        else:
            return 0
1285808
def format_decimal(decimal):
    
    # strip trailing fractional zeros
    normalized = decimal.normalize()
    sign, digits, exponent = normalized.as_tuple()
    if exponent >= 1:
        normalized = normalized.quantize(1)

    return str(normalized)
553487
public static double scaleValue(double value, int decimals) {
    BigDecimal bd = BigDecimal.valueOf(value);
    return bd.setScale(decimals, RoundingMode.HALF_UP).doubleValue();
  }
214817
def fixed(value, places = 2)
      value = value.to_s.to_f unless value.is_a?(Float)
      sprintf("%0.#{places}f", value.round(places))
    end
117541
public static double roundWithDecimalPlace(double doubleNumber,
            int decimalPlace) {
        double pow = pow(10, decimalPlace);
        return Math.round(doubleNumber * pow) / pow;
    }
874783
def num_integral_digits(value)
      case value
      when 0
        ZERO_DIGITS
      when Numeral
        if value.zero?
          ZERO_DIGITS
        else
          if @base != value.base
            value = value.to_base(@base)
          end
          value.normalized(remove_trailing_zeros: true).point
        end
      else
        Conversions.order_of_magnitude(value, base: @base)
      end
    end