当前位置: 首页>>代码示例>>C#>>正文


C# BigInteger.AsUInt64方法代码示例

本文整理汇总了C#中Microsoft.Scripting.Math.BigInteger.AsUInt64方法的典型用法代码示例。如果您正苦于以下问题:C# BigInteger.AsUInt64方法的具体用法?C# BigInteger.AsUInt64怎么用?C# BigInteger.AsUInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Scripting.Math.BigInteger的用法示例。


在下文中一共展示了BigInteger.AsUInt64方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToUInt64

 internal static UInt64 ToUInt64(BigInteger value) {
     UInt64 result;
     if (value.AsUInt64(out result)) {
         return result;
     }
     throw RubyExceptions.CreateRangeError("number too big to convert into System::UInt64");
 }
开发者ID:gregmalcolm,项目名称:ironruby,代码行数:7,代码来源:Converter.cs

示例2: __hash__

        public static int __hash__(BigInteger self) {
#if CLR4 // TODO: we might need our own hash code implementation. This avoids assertion failure.
            if (self == -2147483648) {
                return -2147483648;
            }
#endif

            // check if it's in the Int64 or UInt64 range, and use the built-in hashcode for that instead
            // this ensures that objects added to dictionaries as (U)Int64 can be looked up with Python longs
            Int64 i64;
            if (self.AsInt64(out i64)) {
                return Int64Ops.__hash__(i64);
            } else {
                UInt64 u64;
                if (self.AsUInt64(out u64)) {
                    return UInt64Ops.__hash__(u64);
                }
            }

            // Call the DLR's BigInteger hash function, which will return an int32 representation of
            // b if b is within the int32 range. We use that as an optimization for hashing, and 
            // assert the assumption below.
            int hash = self.GetHashCode();
#if DEBUG
            int i;
            if (self.AsInt32(out i)) {
                Debug.Assert(i == hash, String.Format("hash({0}) == {1}", i, hash));
            }
#endif
            return hash;
        }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:31,代码来源:LongOps.cs

示例3: AsUInt64

 public static bool AsUInt64(BigInteger self, out ulong res) {
     return self.AsUInt64(out res);
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:3,代码来源:LongOps.cs

示例4: ConvertToHostString

 internal static string/*!*/ ConvertToHostString(BigInteger/*!*/ address) {
     Assert.NotNull(address);
     ulong u;
     if (address.AsUInt64(out u)) {
         if (u <= UInt32.MaxValue) {
             // IPv4:
             return ConvertToHostString((uint)u);
         } else {
             // IPv6:
             byte[] bytes = new byte[8];
             for (int i = bytes.Length - 1; i >= 0; --i) {
                 bytes[i] = (byte)(u & 0xff);
                 u >>= 8;
             }
             return new IPAddress(bytes).ToString();
         }
     } else {
         throw RubyExceptions.CreateRangeError("bignum too big to convert into `quad long'");
     }
 }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:20,代码来源:BasicSocket.cs


注:本文中的Microsoft.Scripting.Math.BigInteger.AsUInt64方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。