LongValue() public method

public LongValue ( ) : long
return long
Esempio n. 1
0
 /**
  * Create an Erlang integer from the given value.
  *
  * @param val
  *                the long value to use.
  */
 public OtpErlangLong(BigInteger v)
 {
     if (v == null)
     {
         throw new NullReferenceException();
     }
     if (v.bitCount() < 64)
     {
         val = v.LongValue();
     }
     else
     {
         bigVal = v;
     }
 }
 public void write_big_integer(BigInteger v)
 {
     if (v.bitCount() < 64)
     {
         this.write_long(v.LongValue(), true);
         return;
     }
     int signum = (v > (BigInteger)0) ? 1 : (v < (BigInteger)0) ? -1 : 0;
     if (signum < 0)
     {
         v = -v;
     }
     byte[] magnitude = v.getBytes();
     int n = magnitude.Length;
     // Reverse the array to make it little endian.
     for (int i = 0, j = n; i < j--; i++)
     {
         // Swap [i] with [j]
         byte b = magnitude[i];
         magnitude[i] = magnitude[j];
         magnitude[j] = b;
     }
     if ((n & 0xFF) == n)
     {
         write1(OtpExternal.smallBigTag);
         write1(n); // length
     }
     else
     {
         write1(OtpExternal.largeBigTag);
         write4BE(n); // length
     }
     write1(signum < 0 ? 1 : 0); // sign
     // Write the array
     writeN(magnitude);
 }