Microsoft.Scripting.Math.BigInteger.AsInt32 C# (CSharp) 메소드

AsInt32() 공개 메소드

public AsInt32 ( int &ret ) : bool
ret int
리턴 bool
    public bool AsInt32(out int ret) {
      ret = 0;
      if (sign == 0) return true;
      if (Length > 1) return false;
      if (data[0] > 0x80000000) return false;
      if (data[0] == 0x80000000 && sign == 1) return false;
      ret = (int)data[0];
      ret *= sign;
      return true;
    }

Usage Example

예제 #1
0
파일: Protocols.cs 프로젝트: nieve/ironruby
 /// <summary>
 /// Converts a BigInteger to int if it is small enough
 /// </summary>
 /// <param name="x">The value to convert</param>
 /// <returns>An int if x is small enough, otherwise x.</returns>
 /// <remarks>
 /// Use this helper to downgrade BigIntegers as necessary.
 /// </remarks>
 public static object/*!*/ Normalize(BigInteger/*!*/ x) {
     int result;
     if (x.AsInt32(out result)) {
         return ScriptingRuntimeHelpers.Int32ToObject(result);
     }
     return x;
 }
All Usage Examples Of Microsoft.Scripting.Math.BigInteger::AsInt32