本文整理汇总了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";
}
}
示例2: Coerce
public static RubyArray/*!*/ Coerce(RubyContext/*!*/ context, BigDecimal/*!*/ self, BigInteger/*!*/ other) {
return RubyOps.MakeArray2(BigDecimal.Create(GetConfig(context), other.ToString()), self);
}
示例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;
}
示例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";
}
}
示例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;
}
示例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());
}
示例7: ToString
public static MutableString/*!*/ ToString(BigInteger/*!*/ self) {
return MutableString.CreateAscii(self.ToString());
}
示例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());
}