Shifts floats so that the first 10 decimal digits are significant.
331051
def shift(self, m: Union[float, pd.Series]) -> Union[int, pd.Series]:
        """"""
        out = m % 1 * self.TEN_DIGIT_MODULUS // 1
        if isinstance(out, pd.Series):
            return out.astype(int)
        return int(out)
795209
def _unfloat(flt, precision=5):
    

    if flt == 0.:
        return "{}-0".format("0" * precision)

    num, _, exp = "{:.{}e}".format(flt, precision - 1).partition('e')
    exp = int(exp)
    num = num.replace('.', '')

    return "%s%d" % (num, exp + 1)
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)
1206442
function toPrecision( number, places, truncation ) {
   // Define a maximum precision for truncation=NONE, taking into account 32bit machine limits.
   // We cannot use Number.toFixed because of rounding errors in MSIE8.
   const MAX_SIGNIFICANT_PLACES = 14;

   const actualPlaces = truncation === 'NONE' ? MAX_SIGNIFICANT_PLACES : places;

   if( actualPlaces === 0 ) {
      return `${Math.round( number )}`;
   }

   const multiplier = Math.pow( 10, actualPlaces );
   let str = `${Math.round( number * multiplier ) / multiplier}`;

   // Detect and avoid scientific notation for numbers x where |x| << 10^(-5)
   // A heuristic is used to avoid unnecessary string operations for "regular" numbers
   const absNumber = Math.abs( number );
   if( absNumber < 0.0001 ) {
      const exponent = parseInt( str.split( 'e-' )[ 1 ], 10 );
      if( exponent ) {
         const base = `${Math.pow( 10, exponent - 1 ) * Math.round( absNumber * multiplier ) / multiplier}`;
         str = `${number < 0 ? '-' : ''}0.${zeros( exponent - 1 ) + base.substring( 2 )}`;
      }
   }

   if( truncation === 'BOUNDED' || truncation === 'NONE' ) {
      return str;
   }

   const tmp = str.split( '.' );
   if( tmp.length === 1 ) {
      return `${str}.${zeros( actualPlaces )}`;
   }

   return str + zeros( actualPlaces - tmp[ 1 ].length );
}
517779
def toFloat(val):
    """"""
    hex = "0123456789abcdef"
    return float(hex.find(val[0]) * 16 + hex.find(val[1]))
650429
def _float_to_bits(value, lower=-90.0, middle=0.0, upper=90.0, length=15):
  """"""
  ret = []
  for i in range(length):
    if value >= middle:
      lower = middle
      ret.append(1)
    else:
      upper = middle
      ret.append(0)
    middle = (upper + lower) / 2
  return ret
1231828
function toFixed (value, precision, roundingFunction, optionals) {
    var power = Math.pow(10, precision),
      optionalsRegExp,
      output;

    //roundingFunction = (roundingFunction !== undefined ? roundingFunction : Math.round);
    // Multiply up by precision, round accurately, then divide and use native toFixed():
    output = (roundingFunction(value * power) / power).toFixed(precision);

    if (optionals) {
      optionalsRegExp = new RegExp('0{1,' + optionals + '}$');
      output = output.replace(optionalsRegExp, '');
    }

    return output;
  }
37621
private char [] applyPrecision(int length) {
        char [] result = new char[nDigits];
        for (int i = 0; i < result.length; i++) result[i] = '0';

        if (length >= nDigits || length < 0) {
            // no rounding necessary
            System.arraycopy(digits, 0, result, 0, nDigits);
            return result;
        }
        if (length == 0) {
            // only one digit (0 or 1) is returned because the precision
            // excludes all significant digits
            if (digits[0] >= '5') {
                result[0] = '1';
            }
            return result;
        }

        int i = length;
        int q = digits[i];
        if (q >= '5' && i > 0) {
            q = digits[--i];
            if ( q == '9' ) {
                while ( q == '9' && i > 0 ){
                    q = digits[--i];
                }
                if ( q == '9' ){
                    // carryout! High-order 1, rest 0s, larger exp.
                    result[0] = '1';
                    return result;
                }
            }
            result[i] = (char)(q + 1);
        }
        while (--i >= 0) {
            result[i] = digits[i];
        }
        return result;
    }
90309
def adjust(numeral, round_up)
      check_base numeral
      point, digits = Flt::Support.adjust_digits(
        numeral.point, numeral.digits.digits_array,
        round_mode: @mode,
        negative: numeral.sign == -1,
        round_up: round_up,
        base: numeral.base
      )
      if numeral.zero? && simplifying?
        digits = []
        point = 0
      end
      normalization = simplifying? ? :exact : :approximate
      Numeral[digits, point: point, base: numeral.base, sign: numeral.sign, normalize: normalization]
    end
1109561
static void shiftRight(Slice decimal, int rightShifts, boolean roundUp, Slice result)
    {
        if (rightShifts == 0) {
            copyUnscaledDecimal(decimal, result);
            return;
        }

        int wordShifts = rightShifts / 64;
        int bitShiftsInWord = rightShifts % 64;
        int shiftRestore = 64 - bitShiftsInWord;

        // check round-ups before settings values to result.
        // be aware that result could be the same object as decimal.
        boolean roundCarry;
        if (bitShiftsInWord == 0) {
            roundCarry = roundUp && getLong(decimal, wordShifts - 1) < 0;
        }
        else {
            roundCarry = roundUp && (getLong(decimal, wordShifts) & (1L << (bitShiftsInWord - 1))) != 0;
        }

        // Store negative before settings values to result.
        boolean negative = isNegative(decimal);

        long low;
        long high;

        switch (wordShifts) {
            case 0:
                low = getLong(decimal, 0);
                high = getLong(decimal, 1);
                break;
            case 1:
                low = getLong(decimal, 1);
                high = 0;
                break;
            default:
                throw new IllegalArgumentException();
        }

        if (bitShiftsInWord > 0) {
            low = (low >>> bitShiftsInWord) | (high << shiftRestore);
            high = (high >>> bitShiftsInWord);
        }

        if (roundCarry) {
            if (low != ALL_BITS_SET_64) {
                low++;
            }
            else {
                low = 0;
                high++;
            }
        }

        pack(result, low, high, negative);
    }
744161
def set_decimal(self, pos, decimal):
        
        if pos < 0 or pos > 3:
            # Ignore out of bounds digits.
            return
        # Jump past the colon at position 2 by adding a conditional offset.
        offset = 0 if pos < 2 else 1

        # Calculate the correct position depending on orientation
        if self.invert:
            pos = 4-(pos+offset)
        else:
            pos = pos+offset

        # Set bit 7 (decimal point) based on provided value.
        if decimal:
            self.buffer[pos*2] |= (1 << 7)
        else:
            self.buffer[pos*2] &= ~(1 << 7)
1064584
def decimal_round(number, num_digits, rounding=ROUND_HALF_UP):
    
    exp = Decimal(10) ** -num_digits

    if num_digits >= 0:
        return number.quantize(exp, rounding)
    else:
        return exp * (number / exp).to_integral_value(rounding)
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;
	}
807890
def format_exp_floats(decimals):
    
    threshold = 10 ** 5
    return (
        lambda n: "{:.{prec}e}".format(n, prec=decimals) if n > threshold else "{:4.{prec}f}".format(n, prec=decimals)
    )
140107
public void round(int thePrecision) {
		if (getValue() != null) {
			BigDecimal newValue = getValue().round(new MathContext(thePrecision));
			setValue(newValue);
		}
	}
150498
def shift_right(x, pad_value=None):
  """"""
  if pad_value is None:
    shifted_targets = tf.pad(x, [[0, 0], [1, 0], [0, 0], [0, 0]])[:, :-1, :, :]
  else:
    shifted_targets = tf.concat([pad_value, x], axis=1)[:, :-1, :, :]
  return shifted_targets
1190821
function(key) {
                var key32 = Math.abs(key).toString(32);
                // Get the index of the decimal.
                var decimalIndex = key32.indexOf(".");
                // Remove the decimal.
                key32 = (decimalIndex !== -1) ? key32.replace(".", "") : key32;
                // Get the index of the first significant digit.
                var significantDigitIndex = key32.search(/[^0]/);
                // Truncate leading zeros.
                key32 = key32.slice(significantDigitIndex);
                var sign, exponent = zeros(2), mantissa = zeros(11);

                // Finite cases:
                if (isFinite(key)) {
                    // Negative cases:
                    if (key < 0) {
                        // Negative exponent case:
                        if (key > -1) {
                            sign = signValues.indexOf("smallNegative");
                            exponent = padBase32Exponent(significantDigitIndex);
                            mantissa = flipBase32(padBase32Mantissa(key32));
                        }
                        // Non-negative exponent case:
                        else {
                            sign = signValues.indexOf("bigNegative");
                            exponent = flipBase32(padBase32Exponent(
                                (decimalIndex !== -1) ? decimalIndex : key32.length
                            ));
                            mantissa = flipBase32(padBase32Mantissa(key32));
                        }
                    }
                    // Non-negative cases:
                    else {
                        // Negative exponent case:
                        if (key < 1) {
                            sign = signValues.indexOf("smallPositive");
                            exponent = flipBase32(padBase32Exponent(significantDigitIndex));
                            mantissa = padBase32Mantissa(key32);
                        }
                        // Non-negative exponent case:
                        else {
                            sign = signValues.indexOf("bigPositive");
                            exponent = padBase32Exponent(
                                (decimalIndex !== -1) ? decimalIndex : key32.length
                            );
                            mantissa = padBase32Mantissa(key32);
                        }
                    }
                }
                // Infinite cases:
                else {
                    sign = signValues.indexOf(
                        key > 0 ? "positiveInfinity" : "negativeInfinity"
                    );
                }

                return collations.indexOf("number") + "-" + sign + exponent + mantissa;
            }