I don't seem to find accurate result in arithmetic operation using Int64
var. I need to do average of two Int64
values.
static void Main(string[] args)
{
Int64 avg
int testCase = 0;
testCase = int.Parse(Console.ReadLine());
for (int i = 0; i < testCase; i++)
{
string[] str = Console.ReadLine().Split();
avg = ( ( Int64.Parse( str[0] ) + Int64.Parse( str[1] ) ) / 2 );
Console.WriteLine(avg);
}
}
Input: str[0] == 9082296538332151448
str[1] == 5601337573664003844
Output: -1881554980856698162
Why it's resulting in negative number. Trying to find the average