An int
divided by an int
uses integer truncation.
Use:
static int Main()
{
double d = 1.0 / 7 ;
//^^ or d = 1.0 / 7.0
Console.WriteLine("The value of d is {0}", d) ;
calc(d) ;
return 0 ;
}
Promoting either numerator or denominator (or both) to a floating point type promotes the result of the division to a floating point type.
Refs: