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


C# NumberBuffer类代码示例

本文整理汇总了C#中NumberBuffer的典型用法代码示例。如果您正苦于以下问题:C# NumberBuffer类的具体用法?C# NumberBuffer怎么用?C# NumberBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: HexNumberToInt64

 private static bool HexNumberToInt64(ref NumberBuffer number, ref long value)
 {
     ulong num = 0L;
     bool flag = HexNumberToUInt64(ref number, ref num);
     value = (long) num;
     return flag;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:Number.cs

示例2: HexNumberToInt64

 private static Boolean HexNumberToInt64(ref NumberBuffer number, ref Int64 value)
 {
     UInt64 passedValue = 0;
     Boolean returnValue = HexNumberToUInt64(ref number, ref passedValue);
     value = (Int64)passedValue;
     return returnValue;
 }
开发者ID:nattress,项目名称:corert,代码行数:7,代码来源:FormatProvider.FormatAndParse.cs

示例3: HexNumberToInt32

 private static bool HexNumberToInt32(ref NumberBuffer number, ref int value)
 {
     uint num = 0;
     bool flag = HexNumberToUInt32(ref number, ref num);
     value = (int) num;
     return flag;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:Number.cs

示例4: DoubleToNumber

            private static unsafe void DoubleToNumber(double value, int precision, ref NumberBuffer number)
            {
                number.precision = precision;
                if (DoubleHelper.Exponent(value) == 0x7ff)
                {
                    number.scale = DoubleHelper.Mantissa(value) != 0 ? SCALE_NAN : SCALE_INF;
                    number.sign = DoubleHelper.Sign(value);
                    number.digits[0] = '\0';
                }
                else
                {
                    byte* src = stackalloc byte[_CVTBUFSIZE];
                    int sign;
                    fixed (NumberBuffer* pNumber = &number)
                    {
                        RuntimeImports._ecvt_s(src, _CVTBUFSIZE, value, precision, &pNumber->scale, &sign);
                    }
                    number.sign = sign != 0;

                    char* dst = number.digits;
                    if ((char)*src != '0')
                    {
                        while (*src != 0)
                            *dst++ = (char)*src++;
                    }
                    *dst = '\0';
                }
            }
开发者ID:tijoytom,项目名称:corert,代码行数:28,代码来源:FormatProvider.FormatAndParse.Windows.cs

示例5: HexNumberToUInt32

            private unsafe static Boolean HexNumberToUInt32(ref NumberBuffer number, ref UInt32 value)
            {
                Int32 i = number.scale;
                if (i > UINT32_PRECISION || i < number.precision)
                {
                    return false;
                }
                Char* p = number.digits;
                Debug.Assert(p != null, "");

                UInt32 n = 0;
                while (--i >= 0)
                {
                    if (n > ((UInt32)0xFFFFFFFF / 16))
                    {
                        return false;
                    }
                    n *= 16;
                    if (*p != '\0')
                    {
                        UInt32 newN = n;
                        if (*p != '\0')
                        {
                            if (*p >= '0' && *p <= '9')
                            {
                                newN += (UInt32)(*p - '0');
                            }
                            else
                            {
                                if (*p >= 'A' && *p <= 'F')
                                {
                                    newN += (UInt32)((*p - 'A') + 10);
                                }
                                else
                                {
                                    Debug.Assert(*p >= 'a' && *p <= 'f', "");
                                    newN += (UInt32)((*p - 'a') + 10);
                                }
                            }
                            p++;
                        }

                        // Detect an overflow here...
                        if (newN < n)
                        {
                            return false;
                        }
                        n = newN;
                    }
                }
                value = n;
                return true;
            }
开发者ID:nattress,项目名称:corert,代码行数:53,代码来源:FormatProvider.FormatAndParse.cs

示例6: HexNumberToUInt32

 private static unsafe bool HexNumberToUInt32(ref NumberBuffer number, ref uint value)
 {
     int scale = number.scale;
     if ((scale > 10) || (scale < number.precision))
     {
         return false;
     }
     char* digits = number.digits;
     uint num2 = 0;
     while (--scale >= 0)
     {
         if (num2 > 0xfffffff)
         {
             return false;
         }
         num2 *= 0x10;
         if (digits[0] != '\0')
         {
             uint num3 = num2;
             if (digits[0] != '\0')
             {
                 if ((digits[0] >= '0') && (digits[0] <= '9'))
                 {
                     num3 += digits[0] - '0';
                 }
                 else if ((digits[0] >= 'A') && (digits[0] <= 'F'))
                 {
                     num3 += (uint) ((digits[0] - 'A') + 10);
                 }
                 else
                 {
                     num3 += (uint) ((digits[0] - 'a') + 10);
                 }
                 digits++;
             }
             if (num3 < num2)
             {
                 return false;
             }
             num2 = num3;
         }
     }
     value = num2;
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:45,代码来源:Number.cs

示例7: FormatGeneral

            private static unsafe void FormatGeneral(StringBuilder sb, NumberBuffer number, int nMinDigits, int nMaxDigits, NumberFormatInfo info, char expChar, bool bSuppressScientific)
            {
                int digPos = number.scale;
                bool scientific = false;

                if (!bSuppressScientific)
                {
                    // Don't switch to scientific notation
                    if (digPos > nMaxDigits || digPos < -3)
                    {
                        digPos = 1;
                        scientific = true;
                    }
                }

                char* dig = number.digits;

                if (digPos > 0)
                {
                    do
                    {
                        sb.Append((*dig != 0) ? *dig++ : '0');
                    } while (--digPos > 0);
                }
                else
                {
                    sb.Append('0');
                }

                if (*dig != 0 || digPos < 0)
                {
                    sb.Append(info.NumberDecimalSeparator);

                    while (digPos < 0)
                    {
                        sb.Append('0');
                        digPos++;
                    }

                    while (*dig != 0)
                        sb.Append(*dig++);
                }

                if (scientific)
                    FormatExponent(sb, info, number.scale - 1, expChar, 2, true);
            }
开发者ID:chcosta,项目名称:corefx,代码行数:46,代码来源:FormatProvider.Number.cs

示例8: TryStringToNumber

 internal static bool TryStringToNumber(string str, NumberStyles options, ref NumberBuffer number, NumberFormatInfo numfmt, bool parseDecimal)
 {
     return TryStringToNumber(str, options, ref number, null, numfmt, parseDecimal);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:Number.cs

示例9: TryParseSingle

 internal static unsafe bool TryParseSingle(string value, NumberStyles options, NumberFormatInfo numfmt, out float result)
 {
     byte* stackBuffer = stackalloc byte[0x72];
     NumberBuffer number = new NumberBuffer(stackBuffer);
     result = 0f;
     double num = 0.0;
     if (!TryStringToNumber(value, options, ref number, numfmt, false))
     {
         return false;
     }
     if (!NumberBufferToDouble(number.PackForNative(), ref num))
     {
         return false;
     }
     float f = (float) num;
     if (float.IsInfinity(f))
     {
         return false;
     }
     result = f;
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:Number.cs

示例10: TryParseUInt64

 internal static unsafe bool TryParseUInt64(string s, NumberStyles style, NumberFormatInfo info, out ulong result)
 {
     byte* stackBuffer = stackalloc byte[0x72];
     NumberBuffer number = new NumberBuffer(stackBuffer);
     result = 0L;
     if (!TryStringToNumber(s, style, ref number, info, false))
     {
         return false;
     }
     if ((style & NumberStyles.AllowHexSpecifier) != NumberStyles.None)
     {
         if (!HexNumberToUInt64(ref number, ref result))
         {
             return false;
         }
     }
     else if (!NumberToUInt64(ref number, ref result))
     {
         return false;
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:Number.cs

示例11: ParseDecimal

 internal static unsafe decimal ParseDecimal(string value, NumberStyles options, NumberFormatInfo numfmt)
 {
     byte* stackBuffer = stackalloc byte[0x72];
     NumberBuffer number = new NumberBuffer(stackBuffer);
     decimal num = 0M;
     StringToNumber(value, options, ref number, numfmt, true);
     if (!NumberBufferToDecimal(number.PackForNative(), ref num))
     {
         throw new OverflowException(Environment.GetResourceString("Overflow_Decimal"));
     }
     return num;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:Number.cs

示例12: TryParseDouble

 internal static unsafe bool TryParseDouble(string value, NumberStyles options, NumberFormatInfo numfmt, out double result)
 {
     byte* stackBuffer = stackalloc byte[0x72];
     NumberBuffer number = new NumberBuffer(stackBuffer);
     result = 0.0;
     if (!TryStringToNumber(value, options, ref number, numfmt, false))
     {
         return false;
     }
     if (!NumberBufferToDouble(number.PackForNative(), ref result))
     {
         return false;
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:Number.cs

示例13: NumberToString

            internal static unsafe string NumberToString(NumberBuffer number, char format, int nMaxDigits, NumberFormatInfo info, bool isDecimal)
            {
                int nMinDigits = -1;

                StringBuilder sb = new StringBuilder(MIN_SB_BUFFER_SIZE);

                switch (format)
                {
                    case 'C':
                    case 'c':
                        {
                            nMinDigits = nMaxDigits >= 0 ? nMaxDigits : info.CurrencyDecimalDigits;
                            if (nMaxDigits < 0)
                                nMaxDigits = info.CurrencyDecimalDigits;

                            RoundNumber(ref number, number.scale + nMaxDigits); // Don't change this line to use digPos since digCount could have its sign changed.

                            FormatCurrency(sb, number, nMinDigits, nMaxDigits, info);

                            break;
                        }

                    case 'F':
                    case 'f':
                        {
                            if (nMaxDigits < 0)
                                nMaxDigits = nMinDigits = info.NumberDecimalDigits;
                            else
                                nMinDigits = nMaxDigits;

                            RoundNumber(ref number, number.scale + nMaxDigits);

                            if (number.sign)
                                sb.Append(info.NegativeSign);

                            FormatFixed(sb, number, nMinDigits, nMaxDigits, info, null, info.NumberDecimalSeparator, null);

                            break;
                        }

                    case 'N':
                    case 'n':
                        {
                            if (nMaxDigits < 0)
                                nMaxDigits = nMinDigits = info.NumberDecimalDigits; // Since we are using digits in our calculation
                            else
                                nMinDigits = nMaxDigits;

                            RoundNumber(ref number, number.scale + nMaxDigits);

                            FormatNumber(sb, number, nMinDigits, nMaxDigits, info);

                            break;
                        }

                    case 'E':
                    case 'e':
                        {
                            if (nMaxDigits < 0)
                                nMaxDigits = nMinDigits = 6;
                            else
                                nMinDigits = nMaxDigits;
                            nMaxDigits++;

                            RoundNumber(ref number, nMaxDigits);

                            if (number.sign)
                                sb.Append(info.NegativeSign);

                            FormatScientific(sb, number, nMinDigits, nMaxDigits, info, format);

                            break;
                        }

                    case 'G':
                    case 'g':
                        {
                            bool enableRounding = true;
                            if (nMaxDigits < 1)
                            {
                                if (isDecimal && (nMaxDigits == -1))
                                {
                                    // Default to 29 digits precision only for G formatting without a precision specifier
                                    // This ensures that the PAL code pads out to the correct place even when we use the default precision
                                    nMaxDigits = nMinDigits = DECIMAL_PRECISION;
                                    enableRounding = false;  // Turn off rounding for ECMA compliance to output trailing 0's after decimal as significant
                                }
                                else
                                {
                                    // This ensures that the PAL code pads out to the correct place even when we use the default precision
                                    nMaxDigits = nMinDigits = number.precision;
                                }
                            }
                            else
                                nMinDigits = nMaxDigits;

                            if (enableRounding) // Don't round for G formatting without precision
                                RoundNumber(ref number, nMaxDigits); // This also fixes up the minus zero case
                            else
                            {
//.........这里部分代码省略.........
开发者ID:chcosta,项目名称:corefx,代码行数:101,代码来源:FormatProvider.Number.cs

示例14: FormatNumber

            private static void FormatNumber(StringBuilder sb, NumberBuffer number, int nMinDigits, int nMaxDigits, NumberFormatInfo info)
            {
                string fmt = number.sign ?
                    s_negNumberFormats[info.NumberNegativePattern] :
                    s_posNumberFormat;

                foreach (char ch in fmt)
                {
                    switch (ch)
                    {
                        case '#':
                            FormatFixed(sb, number, nMinDigits, nMaxDigits, info, info.NumberGroupSizes, info.NumberDecimalSeparator, info.NumberGroupSeparator);
                            break;
                        case '-':
                            sb.Append(info.NegativeSign);
                            break;
                        default:
                            sb.Append(ch);
                            break;
                    }
                }
            }
开发者ID:chcosta,项目名称:corefx,代码行数:22,代码来源:FormatProvider.Number.cs

示例15: NumberToInt32

 private static unsafe bool NumberToInt32(ref NumberBuffer number, ref int value)
 {
     int scale = number.scale;
     if ((scale > 10) || (scale < number.precision))
     {
         return false;
     }
     char* digits = number.digits;
     int num2 = 0;
     while (--scale >= 0)
     {
         if (num2 > 0xccccccc)
         {
             return false;
         }
         num2 *= 10;
         if (digits[0] != '\0')
         {
             digits++;
             num2 += digits[0] - '0';
         }
     }
     if (number.sign)
     {
         num2 = -num2;
         if (num2 > 0)
         {
             return false;
         }
     }
     else if (num2 < 0)
     {
         return false;
     }
     value = num2;
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:Number.cs


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