G
Guest
Why do I get different values for the same hex string when parsing to an
integer versus a double? See the follwoing code snippet:
using System;
using System.Collections;
using System.Threading;
public class MyClass
{
public static void Main()
{
double d;
int n;
string str;
str = "8D";
n = int.Parse(str,System.Globalization.NumberStyles.HexNumber);
Console.WriteLine("n is {0}", n);
d = double.Parse(str,System.Globalization.NumberStyles.HexNumber);
Console.WriteLine("d is {0}", d);
Thread.Sleep(5000);
}
}
The integer vlaue is what I expected, 141, whereas the double result is 100.
integer versus a double? See the follwoing code snippet:
using System;
using System.Collections;
using System.Threading;
public class MyClass
{
public static void Main()
{
double d;
int n;
string str;
str = "8D";
n = int.Parse(str,System.Globalization.NumberStyles.HexNumber);
Console.WriteLine("n is {0}", n);
d = double.Parse(str,System.Globalization.NumberStyles.HexNumber);
Console.WriteLine("d is {0}", d);
Thread.Sleep(5000);
}
}
The integer vlaue is what I expected, 141, whereas the double result is 100.