Пример #1
0
 private static void Pad(ref StackBuffer buffer, int digits, bool negSign)
 {
     // add preceding zeros
     while (digits-- > 0)
     {
         buffer.Append('0');
     }
     // add sign
     if (negSign)
     {
         buffer.Append('-');
     }
     // reverse it into the correct order
     buffer.Reverse();
 }
Пример #2
0
        /// <summary>
        /// EvalInt
        /// Converts 16,32bit signed and unsigned ints to ascii
        /// </summary>
        private static void EvalInt(ref StackBuffer buffer, ulong intVal, int digits, ulong baseVal, bool negSign)
        {
            // add the characters in reverse order
            do
            {
                // Lookup from static char array, to cover hex values too
                buffer.Append(asciiDigits[intVal % baseVal]);
                intVal /= baseVal;
                digits--;
            } while (intVal != 0);

            // add preceding zeros
            while (digits-- > 0)
            {
                buffer.Append('0');
            }
            // add sign
            if (negSign)
            {
                buffer.Append('-');
            }
            // reverse it into the correct order
            buffer.Reverse();
        }