Handles numeric values that start with a zero followed by another digit. This is either a timestamp or an
    error.
162539
def _timestamp_zero_start_handler(c, ctx):
    
    val = ctx.value
    ctx.set_ion_type(IonType.TIMESTAMP)
    if val[0] == _MINUS:
        _illegal_character(c, ctx, 'Negative year not allowed.')
    val.append(c)
    c, self = yield
    trans = ctx.immediate_transition(self)
    while True:
        if c in _TIMESTAMP_YEAR_DELIMITERS:
            trans = ctx.immediate_transition(_timestamp_handler(c, ctx))
        elif c in _DIGITS:
            val.append(c)
        else:
            _illegal_character(c, ctx)
        c, _ = yield trans
1049199
float  parseNumber(String input, int startpos, int len)
   {
      boolean  isNegative = false;
      long     significand = 0;
      int      numDigits = 0;
      int      numLeadingZeroes = 0;
      int      numTrailingZeroes = 0;
      boolean  decimalSeen = false;
      int      sigStart;
      int      decimalPos = 0;
      int      exponent;

      long     TOO_BIG = Long.MAX_VALUE / 10;

      pos = startpos;

      if (pos >= len)
        return Float.NaN;  // String is empty - no number found

      char  ch = input.charAt(pos);
      switch (ch) {
         case '-': isNegative = true;
                   // fall through
         case '+': pos++;
      }

      sigStart = pos;

      while (pos < len)
      {
         ch = input.charAt(pos);
         if (ch == '0')
         {
            if (numDigits == 0) {
               numLeadingZeroes++;
            } else {
               // We potentially skip trailing zeroes. Keep count for now.
               numTrailingZeroes++;
            }
         }
         else if (ch >= '1' && ch <= '9')
         {
            // Multiply any skipped zeroes into buffer
            numDigits += numTrailingZeroes;
            while (numTrailingZeroes > 0) {
               if (significand > TOO_BIG) {
                  //Log.e("Number is too large");
                  return Float.NaN;
               }
               significand *= 10;
               numTrailingZeroes--;
            }

            if (significand > TOO_BIG) {
               // We will overflow if we continue...
               //Log.e("Number is too large");
               return Float.NaN;
            }
            significand = significand * 10 + ((int)ch - (int)'0');
            numDigits++;
            
            if (significand < 0)
               return Float.NaN;  // overflowed from +ve to -ve
         }
         else if (ch == '.')
         {
            if (decimalSeen) {
               // Stop parsing here.  We may be looking at a new number.
               break;
            }
            decimalPos = pos - sigStart;
            decimalSeen = true;
         }
         else
            break;
         pos++;
      }

      if (decimalSeen && pos == (decimalPos + 1)) {
         // No digits following decimal point (eg. "1.")
         //Log.e("Missing fraction part of number");
         return Float.NaN;
      }

      // Have we seen anything number-ish at all so far?
      if (numDigits == 0) {
         if (numLeadingZeroes == 0) {
            //Log.e("Number not found");
            return Float.NaN;
         }
         // Leading zeroes have been seen though, so we
         // treat that as a '0'.
         numDigits = 1;
      }

      if (decimalSeen) {
         exponent = decimalPos - numLeadingZeroes - numDigits;
      } else {
         exponent = numTrailingZeroes;
      }

      // Now look for exponent
      if (pos < len)
      {
         ch = input.charAt(pos);
         if (ch == 'E' || ch == 'e')
         {
            boolean  expIsNegative = false;
            int      expVal = 0;
            boolean  abortExponent = false;

            pos++;
            if (pos == len) {
               // Incomplete exponent.
               //Log.e("Incomplete exponent of number");
               return Float.NaN;
            }

            switch (input.charAt(pos)) {
               case '-': expIsNegative = true;
                  // fall through
               case '+': pos++;
                  break;
               case '0': case '1': case '2': case '3': case '4':
               case '5': case '6': case '7': case '8': case '9':
                   break; // acceptable next char
               default:
                  // any other character is a failure, ie no exponent.
                  // Could be something legal like "em" though.
                  abortExponent = true;
                  pos--;  // reset pos to position of 'E'/'e'
            }

            if (!abortExponent)
            {
               int  expStart = pos;

               while (pos < len)
               {
                  ch = input.charAt(pos);
                  if (ch >= '0' && ch <= '9')
                  {
                     if (expVal > TOO_BIG) {
                        // We will overflow if we continue...
                        //Log.e("Exponent of number is too large");
                        return Float.NaN;
                     }
                     expVal = expVal * 10 + ((int)ch - (int)'0');
                     pos++;
                  }
                  else
                     break;
               }

               // Check that at least some exponent digits were read
               if (pos == expStart) {
                  //Log.e(""Incomplete exponent of number"");
                  return Float.NaN;
               }

               if (expIsNegative)
                  exponent -= expVal;
               else
                  exponent += expVal;
            }
         }
      }

      // Quick check to eliminate huge exponents.
      // Biggest float is (2 - 2^23) . 2^127 ~== 3.4e38
      // Biggest negative float is 2^-149 ~== 1.4e-45
      // Some numbers that will overflow will get through the scan
      // and be returned as 'valid', yet fail when value() is called.
      // However they will be very rare and not worth slowing down
      // the parse for.
      if ((exponent + numDigits) > 39 || (exponent + numDigits) < -44)
         return Float.NaN;

      float  f = (float) significand;

      if (significand != 0)
      {
         // Do exponents > 0
         if (exponent > 0)
         {
            f *= positivePowersOf10[exponent];
         }
         else if (exponent < 0)
         {
            // Some valid numbers can have an exponent greater than the max (ie. < -38)
            // for a float.  For example, significand=123, exponent=-40
            // If that's the case, we need to apply the exponent in two steps.
            if (exponent < -38) {
               // Long.MAX_VALUE is 19 digits, so taking 20 off the exponent should be enough. 
               f *= 1e-20;
               exponent += 20;
            }
            // Do exponents < 0
            f *= negativePowersOf10[-exponent];
         }
      }

      return (isNegative) ? -f : f;
   }
181803
def digit(nstr, schema):
    
    if isinstance(nstr, int):
        nstr = str(nstr)
    elif not isinstance(nstr, basestring):
        return False

    return nstr.isdigit()
579631
private static int parseInt(Input s) {
    if (s.index >= s.len) throw new DateFormatException("unexpected end of input", s.str, s.index);
    int result = 0;
    while (s.index < s.len) {
      char c = s.getChar();
      if (c >= '0' && c <= '9') {
        if (result >= Integer.MAX_VALUE / 10) throw new ArithmeticException("Field too large.");
        result = result * 10 + ((int)c - (int)'0');
        s.index++;
      } else {
        break;
      }
    }
    return result;
  }
273037
function zeroPaddingNumber(value, minDigits, maxDigits, buffer) {
        // Optimization for 1, 2 and 4 digit numbers. This should
        // cover most cases of formatting date/time related items.
        // Note: This optimization code assumes that maxDigits is
        // either 2 or Integer.MAX_VALUE (maxIntCount in format()).
        buffer = buffer || [];
        maxDigits = maxDigits || MAX_VALUE;
        if (value >= 0) {
            if (value < 100 && minDigits >= 1 && minDigits <= 2) {
                if (value < 10 && minDigits === 2) {
                    buffer.push(zeroDigit);
                }
                buffer.push(value);
                return buffer.join('');
            } else if (value >= 1000 && value < 10000) {
                if (minDigits === 4) {
                    buffer.push(value);
                    return buffer.join('');
                }
                if (minDigits === 2 && maxDigits === 2) {
                    return zeroPaddingNumber(value % 100, 2, 2, buffer);
                }
            }
        }
        buffer.push(value + '');
        return buffer.join('');
    }
898581
def integer(token):
        
        token = token.strip()
        neg = False
        if token.startswith(compat.b('-')):
            token = token[1:]
            neg = True
        if token.startswith(compat.b('0x')):
            result = int(token, 16)     # hexadecimal
        elif token.startswith(compat.b('0b')):
            result = int(token[2:], 2)  # binary
        elif token.startswith(compat.b('0o')):
            result = int(token, 8)      # octal
        else:
            try:
                result = int(token)     # decimal
            except ValueError:
                result = int(token, 16) # hexadecimal (no "0x" prefix)
        if neg:
            result = -result
        return result
1167977
function num(type, value) {
  var val;
  if(type === NUMERIC.INTEGER) {
    val = utils.strtoint(value);
    if(isNaN(val)) throw IntegerRange;
  }else{
    val = utils.strtofloat(value);
    if(isNaN(val)) throw InvalidFloat;
  }
  return val;
}
132260
def process_number(line, base, str)
      value = str.to_i base
      case value
      when Fixnum
        AST::FixnumLiteral.new line, value
      when Bignum
        AST::NumberLiteral.new line, value
      end
    end
1351507
def replace_zeros(self, val, zero_thresh=0.0):
        
        new_data = self.data.copy()
        new_data[new_data <= zero_thresh] = val
        return type(self)(new_data.astype(self.data.dtype), frame=self._frame)
600503
def _parse_value(self, raw):
        
        try:
            if not raw.startswith("0"):
                val = float(raw)
                if (val % 1) == 0:  # integer
                    val = int(raw)
                    return str(val)

                return self.num_format.format(val)
            else:
                raise ValueError("Cannot parse int!")
        except:
            return str(raw)
566927
function financialNumber (value) {
  const num = Number(value)
  if (value !== num || num < -99999999.99 || num > 99999999.99) {
    throw new Error(`Value '${value}' is not a valid number.`)
  }
}
953118
def to_int(value: str) -> int:
    
    if is_0x_prefixed(value):
        if len(value) == 2:
            return 0
        else:
            return int(value, 16)
    else:
        return int(value)
430011
def _format_num(self, value):
        """"""
        # (value is True or value is False) is ~5x faster than isinstance(value, bool)
        if value is True or value is False:
            raise TypeError('value must be a Number, not a boolean.')
        return self.num_type(value)
1337436
def remove_leading_zeros(num: str) -> str:
    
    if not num:
        return num
    if num.startswith('M'):
        ret = 'M' + num[1:].lstrip('0')
    elif num.startswith('-'):
        ret = '-' + num[1:].lstrip('0')
    else:
        ret = num.lstrip('0')
    return '0' if ret in ('', 'M', '-') else ret
490219
function parseToZeroOrNumber(value, toFloat) {
                    var num = toFloat ? parseFloat(value) : parseInt(value, 10);
                    return isNaN(num) ? 0 : num;
                }
510665
private int convertInt(String input, int defaultValue) {
        try {
            return Integer.parseInt(input.trim());
        } catch (NumberFormatException nfe) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Malformed input: " + input);
            }
            return defaultValue;
        }
    }
509280
def as_int(value, default = 0)
      res = default

      if value
        if value.is_a?(Fixnum)
          res = value
        elsif value.respond_to?(:to_i)
          res = value.to_i
        end
      end

      res
    end