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


C# BigInteger.ToString方法代码示例

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


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

示例1: ToDecimalString

		static string ToDecimalString (string hexString)
		{
#if TARGET_DOTNET
			throw new NotImplementedException ();
#else			
            // http://tools.ietf.org/html/rfc5280#section-4.1.2.2
            // We SHOULD support negative numbers
            var bytes = FromBinHex (hexString);
			
            var negative = bytes.Length > 0 && bytes [0] >= 0x80;
            if (negative) {
                for (int i = 0; i < bytes.Length; i++)
                    bytes [i] = (byte) ~ bytes [i];
            }
        	
			var big = new BigInteger (bytes);
			if (negative) { 
				big = big + 1;
				return "-" + big.ToString ();
			} else 
				return big.ToString ();
#endif
        }
开发者ID:nlhepler,项目名称:mono,代码行数:23,代码来源:X509IssuerSerialKeyIdentifierClause.cs

示例2: GetTrailingZerosCount

        public static int GetTrailingZerosCount(BigInteger num)
        {
            int count = 0;
            string numAsString = num.ToString ();
            int len = numAsString.Length;

            for (int i = 0; i < len; i++)
            {
                int digit = int.Parse (numAsString[len - i - 1].ToString());
                if (digit != 0)
                {
                    break;
                }
                count += 1;
            }

            return count;
        }
开发者ID:gsotirov,项目名称:SoftUni,代码行数:18,代码来源:TrailingZerosInNFactorial.cs

示例3: Convert

        public static string Convert(string source, int sourceRadix, int targetRadix)
        {
            /* Check if radix arguments are within the allowed range. */
            if (sourceRadix < MIN_RADIX || sourceRadix > MAX_RADIX)
                throw new ArgumentOutOfRangeException("sourceRadix", "Source radix needs to be in a range from " + MIN_RADIX + " to " + MAX_RADIX);
            if (targetRadix < MIN_RADIX || targetRadix > MAX_RADIX)
                throw new ArgumentOutOfRangeException("targetRadix", "Target radix needs to be in a range from " + MIN_RADIX + " to " + MAX_RADIX);

            BigInteger radixFrom = new BigInteger((UInt32)sourceRadix);
            BigInteger value = new BigInteger(0);
            BigInteger multiplier = new BigInteger(1);

            for (int i = source.Length - 1; i >= 0; i--)
            {
                int digit = Digit(source[i], sourceRadix);
                if (digit == -1)
                    throw new ArgumentException("The character '" + source[i] + "' is not defined for the source radix.", "sourceRadix");
                value += multiplier * digit;
                multiplier = multiplier * radixFrom;
            }

            return value.ToString((UInt32)targetRadix, CHARACTERS.Substring(0, targetRadix));
        }
开发者ID:heksesang,项目名称:sharpotify,代码行数:23,代码来源:BaseConvert.cs


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