big-endian or motorola format.
340857
public static void writeUnsignedShortBigEndian(byte[] buffer, int offset, int value) {
		buffer[offset++] = (byte)((value >> 8) & 0xFF);
		buffer[offset] = (byte)(value & 0xFF);
	}
1292698
public static void writeIntegerLittleEndian(byte[] buffer, int offset, int value) {
		buffer[offset++] = (byte)(value & 0xFF);
		buffer[offset++] = (byte)((value >> 8) & 0xFF);
		buffer[offset++] = (byte)((value >> 16) & 0xFF);
		buffer[offset] = (byte)((value >> 24) & 0xFF);
	}
351870
public static void writeUnsignedShortLittleEndian(ByteBuffer io, int value) {
		io.put((byte)(value & 0xFF));
		io.put((byte)((value >> 8) & 0xFF));
	}
664460
public static Decimal fromUnscaledBytes(int precision, int scale, byte[] bytes) {
		if (precision > MAX_COMPACT_PRECISION) {
			BigDecimal bd = new BigDecimal(new BigInteger(bytes), scale);
			return new Decimal(precision, scale, -1, bd);
		}
		assert bytes.length == 8;
		long l = 0;
		for (int i = 0; i < 8; i++) {
			l <<= 8;
			l |= (bytes[i] & (0xff));
		}
		return new Decimal(precision, scale, l, null);
	}
549872
def decode_int(v):
    """"""
    if len(v) > 0 and (v[0] == b'\x00' or v[0] == 0):
        raise Exception("No leading zero bytes allowed for integers")
    return big_endian_to_int(v)
161691
private static function set_endianness()
  {
    $packed = pack('d', 1);
    switch ($packed)
    {
      case "\77\360\0\0\0\0\0\0":
        self::$endianness = self::BIG_ENDIAN;
        break;
      case "\0\0\0\0\0\0\360\77":
        self::$endianness = self::LITTLE_ENDIAN;
        break;
      default:
        throw new AvroException(
          sprintf('Error determining platform endianness: %s',
                  AvroDebug::hex_string($packed)));
    }
  }
313855
public static int readIntegerBigEndian(IO.ReadableByteStream io) throws IOException {
		int value = io.read();
		if (value < 0) throw new EOFException();
		value <<= 24;
		int i = io.read();
		if (i < 0) throw new EOFException();
		value |= i << 16;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= i << 8;
		i = io.read();
		if (i < 0) throw new EOFException();
		value |= i;
		return value;
	}
810504
def big_endian(self):
        """"""
        if not self._ptr:
            raise BfdException("BFD not initialized")

        return _bfd.get_bfd_attribute(self._ptr, BfdAttributes.IS_BIG_ENDIAN)
784095
private String format(final long bytes) {
        if (bytes > MB) {
            return String.valueOf(bytes / MB) + " MB";
        }
        return String.valueOf(bytes / KB) + " KB";
    }
1023883
private static String bitsToString(long megabits) {
        int unit = 1000;
        if (megabits < unit) {
            return megabits + " mb";
        }
        int exp = (int) (Math.log(megabits) / Math.log(unit));
        return new DecimalFormat("#.##").format(megabits / Math.pow(unit, exp)) + "GTPE".charAt(exp - 1) + "b";
    }
62146
public static void writeUnsignedShortBigEndian(IO.WritableByteStream io, int value) throws IOException {
		io.write((byte)((value >> 8) & 0xFF));
		io.write((byte)(value & 0xFF));
	}
525235
def to_unit_memory(number):
    """"""
    kb = 1024

    number /= kb

    if number < 100:
        return '{} Kb'.format(round(number, 2))

    number /= kb
    if number < 300:
        return '{} Mb'.format(round(number, 2))

    number /= kb

    return '{} Gb'.format(round(number, 2))
1264267
public void writeRawLittleEndian64(final long value) throws IOException {
    writeRawByte((int)(value      ) & 0xFF);
    writeRawByte((int)(value >>  8) & 0xFF);
    writeRawByte((int)(value >> 16) & 0xFF);
    writeRawByte((int)(value >> 24) & 0xFF);
    writeRawByte((int)(value >> 32) & 0xFF);
    writeRawByte((int)(value >> 40) & 0xFF);
    writeRawByte((int)(value >> 48) & 0xFF);
    writeRawByte((int)(value >> 56) & 0xFF);
  }
277752
public void formatCurrency(
      BigDecimal n, CLDR.Currency currencyCode, StringBuilder destination, CurrencyFormatOptions options) {
    
    DigitBuffer dbuf = new DigitBuffer();
    CurrencyFormatStyle style = options.style();
    NumberFormatMode formatMode = orDefault(options.formatMode(), NumberFormatMode.DEFAULT);
    boolean grouping = orDefault(options.grouping(), true);
    int currencyDigits = getCurrencyDigits(currencyCode);

    switch (style) {
      case SYMBOL:
      case ACCOUNTING:
      {
        NumberPattern[] patterns = style == CurrencyFormatStyle.SYMBOL ? currencyStandard : currencyAccounting;
        NumberPattern pattern = select(n, patterns);
        String symbol = options.symbolWidth() == CurrencySymbolWidth.NARROW 
            ? getNarrowCurrencySymbol(currencyCode) : getCurrencySymbol(currencyCode);
        DigitBuffer other = new DigitBuffer();
        setup(params, pattern, n, other, options, symbol, formatMode, grouping, currencyDigits, -1, -1);
        format(pattern, other, dbuf, symbol, null);
        dbuf.appendTo(destination);
        break;
      }

      case SHORT:
      {
        NumberFormatContext ctx = new NumberFormatContext(options, SIGNIFICANT_MAXFRAC, currencyDigits);
        int nDigits = integerDigits(n);
        int nDivisor = getDivisor_CURRENCY_SHORT(nDigits);

        // Q1 is the number divided by the divisor (if any).
        BigDecimal q1 = n;
        if (nDivisor > 0) {
          q1 = n.movePointLeft(nDivisor).stripTrailingZeros();
        }
        int q1Digits = integerDigits(q1);

        // Select an initial pattern using the OTHER plural category.
        NumberPattern pattern = select(n, getPattern_CURRENCY_SHORT(nDigits, PluralCategory.OTHER));
        
        // Q2 is the number adjusted using the pattern and options.
        ctx.setCompact(pattern, q1Digits, nDivisor);
        BigDecimal q2 = ctx.adjust(q1);
        int q2Digits = integerDigits(q2);

        // Number rounded up, we need to select a new divisor and pattern.
        if (q2Digits > q1Digits) {
          // Bump the number of digits by 1 to select the next divisor/pattern.
          nDigits++;
          int divisor = getDivisor_CURRENCY_SHORT(nDigits);
          pattern = select(n, getPattern_CURRENCY_SHORT(nDigits, PluralCategory.OTHER));
          
          // If divisor changed, we need to divide and adjust again. 
          // Otherwise we just use Q2 as-is.
          if (divisor > nDivisor) {
            q1 = n.movePointLeft(divisor).stripTrailingZeros();
            ctx.setCompact(pattern, integerDigits(q1), divisor);
            q2 = ctx.adjust(q1);
          }
        }

        // Compute the plural category.
        NumberOperands operands = new NumberOperands(q2.toPlainString());
        PluralCategory category = PLURAL_RULES.evalCardinal(bundleId.language(), operands);

        // Select the final pluralized pattern.
        pattern = select(n, getPattern_CURRENCY_SHORT(nDigits, category));
        
        // Format the number into the buffer.
        String symbol = getCurrencySymbol(currencyCode);
        DigitBuffer number = new DigitBuffer();
        NumberFormattingUtils.format(q2, number, params, true, grouping, 
            pattern.format.minimumIntegerDigits,
            currencyStandard[0].format.primaryGroupingSize, 
            currencyStandard[0].format.secondaryGroupingSize);
        
        // Format the entire pattern and append to destination.
        format(pattern, number, dbuf, symbol, null);
        dbuf.appendTo(destination);
        break;
      }
      
      case NAME:
      case CODE:
      {
        // Format the number with generic formatter parameters and grouping off to get the plural category.
        NumberPattern pattern = select(n, decimalStandard);
        DigitBuffer number = new DigitBuffer();
        setup(GENERIC_PARAMS, pattern, n, number, options, null, formatMode, false, currencyDigits, -1, -1);
        
        // Set the operands and get the plural category.
        NumberOperands operands = new NumberOperands(number);
        PluralCategory category = PLURAL_RULES.evalCardinal(bundleId.language(), operands);
        number.reset();

        // Format the number
        setup(params, pattern, n, number, options, null, formatMode, grouping, currencyDigits, -1, -1);
        format(pattern, number, dbuf, null, null);
        
        // Wrap the result with the wrapper selected by the plural category.
        String unit = style == CurrencyFormatStyle.CODE 
            ? currencyCode.toString() 
            : getCurrencyPluralName(currencyCode, category);
        wrapUnits(category, dbuf, unit, destination);
        break;
      }
    }
  }
986966
public static void format(
      BigDecimal n,
      DigitBuffer buf,
      NumberFormatterParams params,
      boolean currencyMode,
      boolean grouping,
      int minIntDigits,
      int primaryGroupingSize,
      int secondaryGroupingSize) {

    // Setup integer digit grouping.
    if (secondaryGroupingSize <= 0) {
      secondaryGroupingSize = primaryGroupingSize;
    }

    // Check if we need to perform digit grouping.
    int groupSize = primaryGroupingSize;
    boolean shouldGroup = false;

    // Output as many integer digits as are available, unless minIntDigits == 0
    // and our value is < 1.
    long intDigits = integerDigits(n);
    if (minIntDigits == 0 && n.compareTo(BigDecimal.ONE) == -1) {
      intDigits = 0;
    } else {
      intDigits = Math.max(intDigits, minIntDigits);
    }

    if (grouping) {
      if (primaryGroupingSize > 0) {
        shouldGroup = intDigits >= (params.minimumGroupingDigits + primaryGroupingSize);
      }
    }

    // Select the decimal and grouping characters.
    String decimal = currencyMode ? params.currencyDecimal : params.decimal;
    String group = currencyMode ? params.currencyGroup : params.group;

    // Keep a pointer to the end of the buffer, since we render the formatted number
    // in reverse to be a bit more compact.
    int bufferStart = buf.length();

    // We only emit the absolute value of the number, since the indication of
    // negative numbers is pattern and locale-specific.
    if (n.signum() == -1) {
      n = n.negate();
    }

    // Translate the standard decimal representation into the localized form.
    // At this point the number of integer and decimal digits is set, all we're
    // doing is outputting the correct decimal symbol and grouping symbols.

    String s = n.toPlainString();
    int end = s.length() - 1;

    // Emit decimal digits and decimal point.
    int idx = s.lastIndexOf('.');
    if (idx != -1) {
      while (end > idx) {
        buf.append(s.charAt(end));
        end--;
      }

      end--;
      buf.append(decimal);
    }

    // Emit integer part with optional grouping
    int emitted = 0;
    while (intDigits > 0 && end >= 0) {
      // Emit grouping digits.
      if (shouldGroup) {
        boolean emit = emitted > 0 && emitted % groupSize == 0;
        if (emit) {
          // Append a grouping character and switch to the secondary grouping size
          buf.append(group);
          emitted -= groupSize;
          groupSize = secondaryGroupingSize;
        }
      }
      buf.append(s.charAt(end));
      end--;
      emitted++;
      intDigits--;
    }

    // Emit zeroes to pad integer part with optional grouping
    if (intDigits > 0) {
      for (int i = 0; i < intDigits; i++) {
        // Emit grouping digits.
        if (shouldGroup) {
          boolean emit = emitted > 0 && emitted % groupSize == 0;
          if (emit) {
            // Append a grouping character and switch to the secondary grouping size
            buf.append(group);
            emitted -= groupSize;
            groupSize = secondaryGroupingSize;
          }
        }
        buf.append('0');
        emitted++;
      }
    }

    buf.reverse(bufferStart);
  }
1348199
def convert(b):
    '''
    
    '''
    if b > 1024**3:
        hr = round(b/1024**3)
        unit = "GB"
    elif b > 1024**2:
        hr = round(b/1024**2)
        unit = "MB"
    else:
        hr = round(b/1024)
        unit = "KB"
    return hr, unit
277709
def header_big_endian(self):
        
        if not self._ptr:
            raise BfdException("BFD not initialized")

        return _bfd.get_bfd_attribute(
            self._ptr, BfdAttributes.HEADER_BIG_ENDIAN)