Given an integer, return a string that is in an approximate, but human
readable format.
It uses the bases 'KiB', 'MiB', and 'GiB' for 1024, 1024**2, and 1024**3.
@param number the number to format
@return a human readable form of the integer
516996
public static String humanReadableInt(long number) {
    DecimalFormat oneDecimal = new DecimalFormat("0.0");
    long absNumber = Math.abs(number);
    double result;
    String prefix = number < 0 ? "-" : "";
    String suffix;
    if (absNumber < 1000) {
      // since no division has occurred, don't format with a decimal point
      return number + " bytes";
    } else if (absNumber < 1000.0 * 1000.0) {
      result = number / 1000.0;
      suffix = " KB";
    } else if (absNumber < 1000.0 * 1000.0 * 1000.0) {
      result = number / (1000.0 * 1000.0);
      suffix = " MB";
    } else {
      result = number / (1000.0 * 1000.0 * 1000.0);
      suffix = " GB";
    }
    return prefix + oneDecimal.format(result) + suffix;
  }
1077726
public static function intToRoman(int $number): string
    {
        if ($number > 4999) {
            return (string) $number;
        }

        $romanNumber = '';
        foreach (static::$romanNumerals as $intNumeral => $romanNumeral) {
            $d = floor($number / $intNumeral);
            $romanNumber .= str_repeat($romanNumeral, $d);
            $number -= $d * $intNumeral;
        }

        return $romanNumber;
    }
272154
public String getIntegerPart(final int digit) {
        
        final int length = integerPart.length();
        if(length < digit || digit <= 0) {
            return "";
        }
        
        String num = String.valueOf(integerPart.charAt(length - digit));
        if(isUseSeparator()) {
            if(digit >= 4 && (digit-1) % 3 == 0) {
                num += ",";
            }
        }
        
        return num;
        
    }
536848
function(number) 
  {
    var bcd = ((number/10)<<4) + (number%10);
    var retVal = bcd.toString(16);
    if( retVal.length < 2 ){
      retVal = '0' + retVal;
    }
    return retVal;
  }
142127
public static String convert(final long number) {
		// 0 to 999 999 999 999
		if (number == 0) {
			return "zero";
		}

		String snumber = Long.toString(number);

		// pad with "0"
		final String mask = "000000000000";
		final DecimalFormat df = new DecimalFormat(mask);
		snumber = df.format(number);

		// XXXnnnnnnnnn
		final int billions = Integer.parseInt(snumber.substring(0, 3));
		// nnnXXXnnnnnn
		final int millions = Integer.parseInt(snumber.substring(3, 6));
		// nnnnnnXXXnnn
		final int hundredThousands = Integer.parseInt(snumber.substring(6, 9));
		// nnnnnnnnnXXX
		final int thousands = Integer.parseInt(snumber.substring(9, 12));

		String tradBillions;
		switch (billions) {
		case 0:
			tradBillions = "";
			break;
		case 1:
			tradBillions = convertLessThanOneThousand(billions) + " Billion ";
			break;
		default:
			tradBillions = convertLessThanOneThousand(billions) + " Billion ";
		}
		String result = tradBillions;

		String tradMillions;
		switch (millions) {
		case 0:
			tradMillions = "";
			break;
		case 1:
			tradMillions = convertLessThanOneThousand(millions) + " Million ";
			break;
		default:
			tradMillions = convertLessThanOneThousand(millions) + " Million ";
		}
		result = result + tradMillions;

		String tradHundredThousands;
		switch (hundredThousands) {
		case 0:
			tradHundredThousands = "";
			break;
		case 1:
			tradHundredThousands = "One Thousand ";
			break;
		default:
			tradHundredThousands = convertLessThanOneThousand(hundredThousands) + " Thousand ";
		}
		result = result + tradHundredThousands;

		String tradThousand;
		tradThousand = convertLessThanOneThousand(thousands);
		result = result + tradThousand;

		// remove extra spaces!
		final String replaceAll = result.replaceAll("^\\s+", "").replaceAll("\\b\\s{2,}\\b", " ");
		return replaceAll.trim();
		// return replaceAll.replace(" ", "_");
	}
254409
private static final String toBrowserHexValue(final int number)
    {
        final String chex = Integer.toHexString(fixRGB(number) & 0xFF).toUpperCase();

        if (chex.length() < 2)
        {
            return "0" + chex;
        }
        return chex;
    }
781574
public static int genLuhn(String number) {
       number = number + "0";
       int s1 = 0, s2 = 0;
       String reverse = new StringBuffer(number).reverse().toString();
       for (int i = 0; i < reverse.length(); i++) {
           int digit = Character.digit(reverse.charAt(i), 10);
           if (i % 2 == 0) {// this is for odd digits, they are 1-indexed in //
                            // the algorithm
               s1 += digit;
           } else {// add 2 * digit for 0-4, add 2 * digit - 9 for 5-9
               s2 += 2 * digit;
               if (digit >= 5) {
                   s2 -= 9;
               }
           }
       }
       int check = 10 - ((s1 + s2) % 10);
       if (check == 10)
           check = 0;
       return check;
   }
146074
protected String getNumberedName(String name, int number) {

        if (number == 0) {
            return name;
        }
        PrintfFormat fmt = new PrintfFormat("%0.6d");
        return name + "_" + fmt.sprintf(number);
    }
44175
def human_readable_number(number, suffix=""):
    
    for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]:
        if abs(number) < 1024.0:
            return "%3.1f%s%s" % (number, unit, suffix)
        number /= 1024.0
    return "%.1f%s%s" % (number, "Y", suffix)
532834
public static String intToHex(int number, int hexSize) {
        String tmp = Integer.toHexString(number & 0xFF);
        while (tmp.length() < hexSize) {
            tmp = "0" + tmp;
        }
        return tmp;
    }
1370243
def get_readable_string(integer):
    
    """
    if integer == 9:    #\t
        readable_string = "\\t"
    elif integer == 10: #\r
        readable_string = "\\r"
    elif integer == 13:  #\n
        readable_string = "\\n"
    elif integer == 32:  # space
        readable_string = '__'
    elif integer >= 33 and integer <= 126:  # Readable ascii
        readable_string = ''.join([chr(integer), '.'])
    else:  # rest
        readable_string = int_to_padded_hex_byte(integer)

    return readable_string
607884
def human_readable_digit(number):
    

    if 0 >= number:
        return "{0:.1f} ".format(number)

    word = ["", "thousand", "million", "billion", "trillion"]
    millidx = max(0, min(len(word)-1, int(np.floor(np.log10(abs(number))/3.0))))
    return "{0:.1f} {1}".format(number/10**(3*millidx), word[millidx])
1123860
public static String toUidString(int number) {
        StringBuilder builder = new StringBuilder();
        while (number > 0) {
            builder.append(UID[number % UID_LENGTH]);
            number /= UID_LENGTH;
        }
        return builder.toString();
    }
115277
def _convert_number(self, number):
        """"""

        number = float(number)
        return int(number) if number.is_integer() else float(number)
1130224
def format_number(number, format):
    """"""
    if format == NumberFormat.NUMBER:
        return str(number)
    elif format == NumberFormat.LOWERCASE_CHARACTER:
        string = ''
        while number > 0:
            number, ordinal = divmod(number, 26)
            if ordinal == 0:
                ordinal = 26
                number -= 1
            string = chr(ord('a') - 1 + ordinal) + string
        return string
    elif format == NumberFormat.UPPERCASE_CHARACTER:
        return format_number(number, 'lowercase character').upper()
    elif format == NumberFormat.LOWERCASE_ROMAN:
        return romanize(number).lower()
    elif format == NumberFormat.UPPERCASE_ROMAN:
        return romanize(number)
    elif format == NumberFormat.SYMBOL:
        return symbolize(number)
    elif format == NumberFormat.NONE:
        return ''
    else:
        raise ValueError("Unknown number format '{}'".format(format))
899986
public static String ordinalize(int number){
        int modulo = number%100;
        if(modulo>=11 && modulo<=13)
            return number+"th";
        switch(number%10){
            case 1:
                return number+"st";
            case 2:
                return number+"nd";
            case 3:
                return number+"rd";
            default:
                return number+"th";
        }
    }
1056678
private function numToString(BigNumber $number) : string
    {
        $output = '';
        while ($number->getValue() > 0) {
            $previousNumber = clone $number;
            $number = $number->divide($this->alphabetLength);
            $digit = $previousNumber->mod($this->alphabetLength);

            $output .= $this->alphabet[(int)$digit->getValue()];
        }

        return $output;
    }