System.Globalization.CharUnicodeInfo.InternalGetNumericValue C# (CSharp) Method

InternalGetNumericValue() static private method

static private InternalGetNumericValue ( int ch ) : double
ch int
return double
        internal unsafe static double InternalGetNumericValue(int ch) {
            BCLDebug.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range.");
            // Get the level 2 item from the highest 12 bit (8 - 19) of ch.
            ushort index = m_pNumericLevel1Index[ch >> 8];
            // Get the level 2 WORD offset from the 4 - 7 bit of ch.  This provides the base offset of the level 3 table.
            // The offset is referred to an float item in m_pNumericFloatData.
            // Note that & has the lower precedence than addition, so don't forget the parathesis.
            index = m_pNumericLevel1Index[index + ((ch >> 4) & 0x000f)];
            byte* pBytePtr = (byte*)&(m_pNumericLevel1Index[index]);
            // Get the result from the 0 -3 bit of ch.
            return (((double*)m_pNumericValues)[pBytePtr[(ch & 0x000f)]]);
        }

Usage Example

Example #1
0
 public static double GetNumericValue(string s, int index)
 {
     if (s == null)
     {
         throw new ArgumentNullException("s");
     }
     if (index < 0 || index >= s.Length)
     {
         throw new ArgumentOutOfRangeException("index", Environment.GetResourceString("ArgumentOutOfRange_Index"));
     }
     return(CharUnicodeInfo.InternalGetNumericValue(CharUnicodeInfo.InternalConvertToUtf32(s, index)));
 }
All Usage Examples Of System.Globalization.CharUnicodeInfo::InternalGetNumericValue