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


C# BigInteger.ToString方法代码示例

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


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

示例1: __hex__

 public static string __hex__(BigInteger x) {
     // CPython 2.5 prints letters in lowercase, with a capital L. 
     if (x < 0) {
         return "-0x" + (-x).ToString(16).ToLower() + "L";
     } else {
         return "0x" + x.ToString(16).ToLower() + "L";
     }
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:8,代码来源:LongOps.cs

示例2: Coerce

 public static RubyArray/*!*/ Coerce(RubyContext/*!*/ context, BigDecimal/*!*/ self, BigInteger/*!*/ other) {
     return RubyOps.MakeArray2(BigDecimal.Create(GetConfig(context), other.ToString()), self);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:3,代码来源:BigDecimalOps.cs

示例3: ToExponent

        private static string/*!*/ ToExponent(BigInteger/*!*/ self, bool lower, int minPrecision, int maxPrecision) {
            Debug.Assert(minPrecision <= maxPrecision);

            // get all the digits
            string digits = self.ToString();

            StringBuilder tmp = new StringBuilder();
            tmp.Append(digits[0]);
            
            for (int i = 1; i < maxPrecision && i < digits.Length; i++) {
                // append if we have a significant digit or if we are forcing a minimum precision
                if (digits[i] != '0' || i <= minPrecision) {
                    if (tmp.Length == 1) {
                        // first time we've appended, add the decimal point now
                        tmp.Append('.');
                    }

                    while (i > tmp.Length - 1) {
                        // add any digits that we skipped before
                        tmp.Append('0');
                    }

                    // round up last digit if necessary
                    if (i == maxPrecision - 1 && i != digits.Length - 1 && digits[i + 1] >= '5') {
                        tmp.Append((char)(digits[i] + 1));
                    } else {
                        tmp.Append(digits[i]);
                    }
                }
            }

            if (digits.Length <= minPrecision) {
                if (tmp.Length == 1) {
                    // first time we've appended, add the decimal point now
                    tmp.Append('.');
                }

                while (minPrecision >= tmp.Length - 1) {
                    tmp.Append('0');
                }
            }

            tmp.Append(lower ? "e+" : "E+");
            int digitCnt = digits.Length - 1;
            if (digitCnt < 10) {
                tmp.Append('0');
                tmp.Append((char)('0' + digitCnt));
            } else {
                tmp.Append(digitCnt.ToString());
            }

            digits = tmp.ToString();
            return digits;
        }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:54,代码来源:LongOps.cs

示例4: __oct__

 public static string __oct__(BigInteger x) {
     if (x == BigInteger.Zero) {
         return "0L";
     } else if (x > 0) {
         return "0" + x.ToString(8) + "L";
     } else {
         return "-0" + (-x).ToString(8) + "L";
     }
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:9,代码来源:LongOps.cs

示例5: ToCultureString

        private static string/*!*/ ToCultureString(BigInteger/*!*/ val, CultureInfo/*!*/ ci) {
            string digits;
            string separator = ci.NumberFormat.NumberGroupSeparator;
            int[] separatorLocations = ci.NumberFormat.NumberGroupSizes;
            digits = val.ToString();

            if (separatorLocations.Length > 0) {
                StringBuilder res = new StringBuilder(digits);

                int curGroup = 0, curDigit = digits.Length - 1;
                while (curDigit > 0) {
                    // insert the seperator
                    int groupLen = separatorLocations[curGroup];
                    if (groupLen == 0) {
                        break;
                    }
                    curDigit -= groupLen;

                    if (curDigit >= 0) {
                        res.Insert(curDigit + 1, separator);
                    }

                    // advance the group
                    if (curGroup + 1 < separatorLocations.Length) {
                        if (separatorLocations[curGroup + 1] == 0) {
                            // last value doesn't propagate
                            break;
                        }

                        curGroup++;
                    }
                }

                digits = res.ToString();
            }

            return digits;
        }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:38,代码来源:LongOps.cs

示例6: ToString

        public static object ToString(BigInteger/*!*/ self, uint radix) {
            if (radix < 2 || radix > 36) {
                throw RubyExceptions.CreateArgumentError(String.Format("illegal radix {0}", radix));
            }

            // TODO: Can we do the ToLower in BigInteger?
            return MutableString.Create(self.ToString((uint)radix).ToLower());
        }
开发者ID:joshholmes,项目名称:ironruby,代码行数:8,代码来源:BigNumOps.cs

示例7: ToString

 public static MutableString/*!*/ ToString(BigInteger/*!*/ self) {
     return MutableString.CreateAscii(self.ToString());
 }
开发者ID:techarch,项目名称:ironruby,代码行数:3,代码来源:ClrBigInteger.cs

示例8: ToString

        public static MutableString/*!*/ ToString(BigInteger/*!*/ self, int radix) {
            if (radix < 2 || radix > 36) {
                throw RubyExceptions.CreateArgumentError("illegal radix {0}", radix);
            }

            // TODO: Can we do the ToLower in BigInteger?
            return MutableString.CreateAscii(self.ToString(radix).ToLowerInvariant());
        }
开发者ID:kevinkeeney,项目名称:ironruby,代码行数:8,代码来源:ClrBigInteger.cs


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