Rhino.Decompiler.PrintSourceNumber C# (CSharp) Method

PrintSourceNumber() private static method

private static PrintSourceNumber ( string source, int offset, StringBuilder sb ) : int
source string
offset int
sb StringBuilder
return int
		private static int PrintSourceNumber(string source, int offset, StringBuilder sb)
		{
			double number = 0.0;
			char type = source[offset];
			++offset;
			if (type == 'S')
			{
				if (sb != null)
				{
					int ival = source[offset];
					number = ival;
				}
				++offset;
			}
			else
			{
				if (type == 'J' || type == 'D')
				{
					if (sb != null)
					{
						long lbits;
						lbits = (long)source[offset] << 48;
						lbits |= (long)source[offset + 1] << 32;
						lbits |= (long)source[offset + 2] << 16;
						lbits |= source[offset + 3];
						if (type == 'J')
						{
							number = lbits;
						}
						else
						{
							number = System.BitConverter.Int64BitsToDouble(lbits);
						}
					}
					offset += 4;
				}
				else
				{
					// Bad source
					throw new Exception();
				}
			}
			if (sb != null)
			{
				sb.Append(ScriptRuntime.NumberToString(number, 10));
			}
			return offset;
		}