Converts a Java long to a Big Endian int on 8 bytes.

@param value is the value to parse.
@return the parsing result
497911
@Pure
	public static byte[] parseBELong(long value) {
		return new byte[] {
			(byte) ((value >> 56) & 0xFF),
			(byte) ((value >> 48) & 0xFF),
			(byte) ((value >> 40) & 0xFF),
			(byte) ((value >> 32) & 0xFF),
			(byte) ((value >> 24) & 0xFF),
			(byte) ((value >> 16) & 0xFF),
			(byte) ((value >> 8) & 0xFF),
			(byte) (value & 0xFF),
		};
    }
479850
public static long getLong(
    Object      value)
  {
    if (value == null)
    {
        return 0;
    }

    return Long.valueOf(value.toString()).longValue();
  }
637321
public static byte[] getBytesLittleEndian(long value) {
		byte[] b = new byte[8];
		b[0] = (byte)(value & 0xFF);
		b[1] = (byte)((value >> 8) & 0xFF);
		b[2] = (byte)((value >> 16) & 0xFF);
		b[3] = (byte)((value >> 24) & 0xFF);
		b[4] = (byte)((value >> 32) & 0xFF);
		b[5] = (byte)((value >> 40) & 0xFF);
		b[6] = (byte)((value >> 48) & 0xFF);
		b[7] = (byte)((value >> 56) & 0xFF);
		return b;
	}
771263
private static Object toLong( BigDecimal value)
    {
    Object number;
        
    try
      {
      number =
        value.scale() == 0
        ? Long.valueOf( value.longValueExact())
        : null;
      }
    catch( Exception e)
      {
      number = null;
      }
        
    return number;
    }
931893
public static void writeLongLittleEndian(ByteBuffer io, long value) {
		io.put((byte)(value & 0xFF));
		io.put((byte)((value >> 8) & 0xFF));
		io.put((byte)((value >> 16) & 0xFF));
		io.put((byte)((value >> 24) & 0xFF));
		io.put((byte)((value >> 32) & 0xFF));
		io.put((byte)((value >> 40) & 0xFF));
		io.put((byte)((value >> 48) & 0xFF));
		io.put((byte)((value >> 56) & 0xFF));
	}
745902
public JBBPTextWriter Int(final int value) throws IOException {
    ensureValueMode();

    String convertedByExtras = null;
    for (final Extra e : this.extras) {
      convertedByExtras = e.doConvertIntToStr(this, value);
      if (convertedByExtras != null) {
        break;
      }
    }

    if (convertedByExtras == null) {
      final long valueToWrite;
      if (this.byteOrder == JBBPByteOrder.LITTLE_ENDIAN) {
        valueToWrite = JBBPUtils.reverseByteOrder(value, 4);
      } else {
        valueToWrite = value;
      }
      printValueString(JBBPUtils.ensureMinTextLength(JBBPUtils.ulong2str(valueToWrite & 0xFFFFFFFFL, this.radix, CHAR_BUFFER), this.maxCharsRadixForInt, '0', 0));
    } else {
      printValueString(convertedByExtras);
    }
    return this;
  }
300444
public static long asLong(Object value) {
        if (value instanceof Number) {
            return ((Number) value).longValue();
        } else if (value instanceof Numeric) {
            return ((Numeric) value).asInteger();
        } else if (value instanceof Boolean) {
            return ((Boolean) value) ? 1L : 0L;
        } else if (value instanceof CharSequence) {
            try {
                return Long.parseLong(value.toString());
            } catch (NumberFormatException nfe) {
                throw new IncompatibleValueException("Unable to parse string \"" + Strings.escape(value.toString()) +
                                                     "\" to a long", nfe);
            }
        } else if (value instanceof Date) {
            // Return date timestamp.
            return ((Date) value).getTime();
        }
        throw new IncompatibleValueException("Unable to convert " + value.getClass().getSimpleName() + " to a long");

    }
485330
public static long doubleToSortableLong(double value)
    {
        long bits = Double.doubleToLongBits(value);
        return bits ^ (bits >> 63) & Long.MAX_VALUE;
    }
631863
public int intValue() throws OtpErlangRangeException {
        final long l = longValue();
        final int i = (int) l;

        if (i != l) {
            throw new OtpErlangRangeException("Value too large for int: " + val);
        }

        return i;
    }
1113028
private BigInteger toBigInteger(Object value) {
		if (value instanceof Long) {
			return BigInteger.valueOf((Long) value);
		} else if(value instanceof Boolean) {
			return BigInteger.valueOf((boolean)value ? 1 : 0);
		}
		final String valueStr = convertToStr(value);
		if (StrUtil.isBlank(valueStr)) {
			return null;
		}
		return new BigInteger(valueStr);
	}
420944
public static void writeLongLittleEndian(IO.WritableByteStream io, long value) throws IOException {
		io.write((byte)(value & 0xFF));
		io.write((byte)((value >> 8) & 0xFF));
		io.write((byte)((value >> 16) & 0xFF));
		io.write((byte)((value >> 24) & 0xFF));
		io.write((byte)((value >> 32) & 0xFF));
		io.write((byte)((value >> 40) & 0xFF));
		io.write((byte)((value >> 48) & 0xFF));
		io.write((byte)((value >> 56) & 0xFF));
	}
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);
  }
468901
private static String unsignedToString(final long value) {
    if (value >= 0) {
      return Long.toString(value);
    } else {
      // Pull off the most-significant bit so that BigInteger doesn't think
      // the number is negative, then set it again using setBit().
      return BigInteger.valueOf(value & 0x7FFFFFFFFFFFFFFFL)
                       .setBit(63).toString();
    }
  }
189884
public static Integer parseInteger(String value) throws ParseException
   {
      Integer result = null;

      if (value.length() > 0 && value.indexOf(' ') == -1)
      {
         if (value.indexOf('.') == -1)
         {
            result = Integer.valueOf(value);
         }
         else
         {
            Number n = DatatypeConverter.parseDouble(value);
            result = Integer.valueOf(n.intValue());
         }
      }

      return result;
   }
807915
public static void writeUnsignedIntegerLittleEndian(byte[] buffer, int offset, long value) {
		buffer[offset++] = (byte)(value & 0xFF);
		buffer[offset++] = (byte)((value >> 8) & 0xFF);
		buffer[offset++] = (byte)((value >> 16) & 0xFF);
		buffer[offset] = (byte)((value >> 24) & 0xFF);
	}
190841
public static IntegerBinding toIntExact(final ObservableLongValue value) {
        return createIntegerBinding(() -> Math.toIntExact(value.get()), value);
    }
192021
public static void writeUnsignedIntegerLittleEndian(ByteBuffer io, long value) {
		io.put((byte)(value & 0xFF));
		io.put((byte)((value >> 8) & 0xFF));
		io.put((byte)((value >> 16) & 0xFF));
		io.put((byte)((value >> 24) & 0xFF));
	}